SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Hybrid View

  1. #1
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Controlling text field width with JS

    Iím using the following Java Script to set the width of text fields:

    <SCRIPT>
    if (navigator.appName == 'Netscape') {
    document.write('<INPUT type="text" name="textfield" maxlenght="30" class="forms" size=14>\n');
    } else {
    document.write('<INPUT type="text" name="textfield" maxlenght="30" class="forms" size=30>\n');
    }
    </SCRIPT>

    How do I use that script to set the width of the text area field below?

    <textarea name="textfield2" cols="50" rows="6" class="forms"> </textarea>

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Modify the cols= part...

  3. #3
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How? And where do I put the </textarea> tag?

  4. #4
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just copy and paste the entire line over the old <input> one (including the </textarea>) and change the cols on one of them.

  5. #5
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So it really was that easy. I'll try that, thanx Anarchos!

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, also: you have "maxlength" spelled as "maxnlenght" -- typo!

  7. #7
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is very strange... This code makes a text area field in IE 5.5 but nothing in NN 4.7.

    if (navigator.appName == 'Netscape') {
    document.write('<textarea name="textfield3" cols="25" rows="6" class="forms"></textarea>\n');
    } else {
    document.write('<textarea name="textfield3" cols="50" rows="6" class="forms"></textarea>\n');
    }

    What have I done wrong?

  8. #8
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I remove the class="forms" from the code the textarea field appears in NN. But I really want to use CSS...

  9. #9
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Netscape doesn't support very much CSS for form elements, what does the forms class have in it?

  10. #10
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The same as the the other text fields that work just fine:

    .forms { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; background-color: #333333; border: 1px #999999 solid; font-weight: bold}

  11. #11
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the effect that Iím trying to achieve. It's a screenshot from IE 5.5. Netscape displays the name and the e-mail text fields correctly but the message text area field is missing.

    I have tried to use IDs instead of classes (# instead of the dot in the <head> and id= instead of class= in the body like so:

    <head>
    <style type="text/css">
    <!--
    #form{font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; background-color: #333333; border: 1px #999999 solid; font-weight: bold}
    -->
    </style>
    </head>


    <body>
    <SCRIPT>
    if (navigator.appName == 'Netscape') {
    document.write('<textarea name="textfield3" cols="25" rows="6" class="forms"></textarea>\n');
    } else {
    document.write('<textarea name="textfield3" cols="50" rows="6" class="forms"></textarea>\n');
    }
    </SCRIPT>
    </body>

    But Netscape does still refuse to show the last field. Any ideas?

  12. #12
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Marina,
    Like Anarchos said...Netscape doesn't have very good support for CSS in forms. It doesn't matter how you try to do it, I don't think you can ever guarantee it will look right in Netscape. You might try to redirect to a Netscape friendly page for this.....sorry.

    Sketch
    Aaron Brazell
    Technosailor



  13. #13
    Next stop: PHP! Marina's Avatar
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are right, I just discovered that CSS in forms only is supported in NS6. Thanx, for trying anyway!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •