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>
How? And where do I put the </textarea> tag?
Just copy and paste the entire line over the old <input> one (including the </textarea>) and change the cols on one of them.
So it really was that easy. I'll try that, thanx Anarchos!
Oh, also: you have "maxlength" spelled as "maxnlenght" -- typo!
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?
If I remove the class="forms" from the code the textarea field appears in NN. But I really want to use CSS...
Netscape doesn't support very much CSS for form elements, what does the forms class have in it?
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}
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?
Prolific Blogger
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
You are right, I just discovered that CSS in forms only is supported in NS6. Thanx, for trying anyway!
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks