Loading ...
Sorry, an error occurred while loading the content.
 

Re: [JavaScript] Changing font size in the textbox.

Expand Messages
  • soren.j.winslow@cummins.com
    This is how I do it...... Font Size:
    Message 1 of 4 , Jan 5, 2004
      This is how I do it......

      <form name="SomeForm">

      Font Size:
      <selelect name="TheFontSize"
      onchange="SomeForm.TheTextArea.fontSize=SomeForm.TheFontSize.value">
      <option value="10pt">10 pt</option>
      <option value="11pt">11 pt</option>
      <option value="12pt">12 pt</option>
      <option value="13pt">13 pt</option>
      </select>

      <textarea name="TheTextArea"></textarea>

      </form>


      Soren






      zeshanism <no_reply@yahoogroups.com>
      01/03/2004 17:34
      Please respond to javascript_official

      To: javascript_official@yahoogroups.com
      cc:
      Subject: [JavaScript] Changing font size in the textbox.


      A newbie is seeking help here. I made a script and its working fine
      to change the font size within a textarea.

      Now the problem is when I enclose the <select> and <textarea> within
      the form tags, it gives error. Line 14 "object or property not
      supported".

      --------------------------------------------------------
      <html>
      <head>
      <script language="JavaScript">
      function lettertype(elmnt)
      {
      var textarea =

      document.getElementById('trans');
      textarea.style.fontSize = elmnt.value;
      }
      </script>

      </head>
      <body>
      Select Font Size: <select name="lettertype"

      onchange="lettertype(this);">
      <option value="12">12</option>
      <option value="14">14</option>
      <option value="16">16</option>
      <option value="18">18</option>
      <option value="20">20</option>
      <option value="22">22</option>
      <option value="24">24</option>
      times
      </option>
      </select> <br><br>
      <textarea id="trans" rows=10 cols=10></textarea>
      </body>

      </html>
      ------------------------------------------------------
      Any help would be greatly appreciated.

      Thanks,
      Zeshan.








      Yahoo! Groups Links

      To visit your group on the web, go to:
      http://groups.yahoo.com/group/javascript_official/

      To unsubscribe from this group, send an email to:
      javascript_official-unsubscribe@yahoogroups.com

      Your use of Yahoo! Groups is subject to:
      http://docs.yahoo.com/info/terms/





      [Non-text portions of this message have been removed]
    • David Smart
      The problem is that you have both a field and a function called lettertype . Change one of them and it works inside a form. (No idea why it worked OK outside
      Message 2 of 4 , Jan 5, 2004
        The problem is that you have both a field and a function called "lettertype". Change one of them and it works inside a form.

        (No idea why it worked OK outside a form with the two names the same.)

        Regards, David Smart

        SmartWare Consulting
        smartware@...
        http://members.optushome.com.au/smartware/

        ----- Original Message -----
        From: zeshanism
        To: javascript_official@yahoogroups.com
        Sent: Sunday, January 04, 2004 12:34 PM
        Subject: [JavaScript] Changing font size in the textbox.


        A newbie is seeking help here. I made a script and its working fine
        to change the font size within a textarea.

        Now the problem is when I enclose the <select> and <textarea> within
        the form tags, it gives error. Line 14 "object or property not
        supported".

        --------------------------------------------------------
        <html>
        <head>
        <script language="JavaScript">
        function lettertype(elmnt)
        {
        var textarea =

        document.getElementById('trans');
        textarea.style.fontSize = elmnt.value;
        }
        </script>

        </head>
        <body>
        Select Font Size: <select name="lettertype"

        onchange="lettertype(this);">
        <option value="12">12</option>
        <option value="14">14</option>
        <option value="16">16</option>
        <option value="18">18</option>
        <option value="20">20</option>
        <option value="22">22</option>
        <option value="24">24</option>
        times
        </option>
        </select> <br><br>
        <textarea id="trans" rows=10 cols=10></textarea>
        </body>

        </html>
        ------------------------------------------------------
        Any help would be greatly appreciated.

        Thanks,
        Zeshan.





        Yahoo! Groups Sponsor
        ADVERTISEMENT





        ------------------------------------------------------------------------------
        Yahoo! Groups Links

        a.. To visit your group on the web, go to:
        http://groups.yahoo.com/group/javascript_official/

        b.. To unsubscribe from this group, send an email to:
        javascript_official-unsubscribe@yahoogroups.com

        c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



        [Non-text portions of this message have been removed]
      • Jon Stephens
        function changeFontSize(el); { var textarea = document.getElementById( trans ); textarea.style.fontSize =
        Message 3 of 4 , Jan 5, 2004
          <html>
          <head>
          <script type="text/javascript">
          function changeFontSize(el);
          {
          var textarea = document.getElementById("trans");
          textarea.style.fontSize = el.options[el.selectedIndex].value + "px";
          }
          </script>
          </head>
          <body>
          <p>Select Font Size:
          <select onchange="changeFontSize(this);">
          <option value="12">12</option>
          <option value="14">14</option>
          <option value="16">16</option>
          <option value="18">18</option>
          <option value="20">20</option>
          <option value="22">22</option>
          <option value="24">24</option>
          </select> </p>
          <p><textarea id="trans" rows=10 cols=10>Some text...</textarea></p>
          </body>
          </html>

          1. Per the W3C CSS specifications, all style values involving sizes/lengths *must include
          units*. Sole exception: the value 0 (zero). It doesn't matter whether you set a size or length
          in CSS or via DOM, any nonzero value must include a unit of measurement (px, pt, em, whatever).
          MSIE lets you get away not doing this and defaults to pt. This is incorrect bahaviour and other
          browsers don't do this. Also per the DOM specs, style rules are string values. Again MSIE lets
          you cheat in this regard, but other browsers don't.

          Wrong: document.getElementById("myEl").style.width = 350;
          Right: document.getElementById("myEl").style.width = "350px";

          2. The value of a selected option is selectObj.options[selectObj.selectedIndex].value.
          selectObj.value is an MSIE-only shortcut, and does not work in other browsers.

          > Date: Sun, 04 Jan 2004 01:34:44 -0000
          > From: zeshanism
          > Subject: Changing font size in the textbox.
          >
          > A newbie is seeking help here. I made a script and its working fine
          > to change the font size within a textarea.
          >
          > Now the problem is when I enclose the <select> and <textarea> within
          > the form tags, it gives error. Line 14 "object or property not
          > supported".
          >
          > --------------------------------------------------------
          > <html>
          > <head>
          > <script language="JavaScript">
          > function lettertype(elmnt)
          > {
          > var textarea =
          >
          > document.getElementById('trans');
          > textarea.style.fontSize = elmnt.value;
          > }
          > </script>
          >
          > </head>
          > <body>
          > Select Font Size: <select name="lettertype"
          >
          > onchange="lettertype(this);">
          > <option value="12">12</option>
          > <option value="14">14</option>
          > <option value="16">16</option>
          > <option value="18">18</option>
          > <option value="20">20</option>
          > <option value="22">22</option>
          > <option value="24">24</option>
          > times
          > </option>
          > </select> <br><br>
          > <textarea id="trans" rows=10 cols=10></textarea>
          > </body>
          >
          > </html>
        Your message has been successfully submitted and would be delivered to recipients shortly.