Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assigning className to an input tag

Status
Not open for further replies.

avivit

Technical User
Jul 5, 2000
456
IL

Hi all,
I'd like to assign &quot;className&quot; to an <input> tag, but I don't manage to do that.
I tried using :
document.form1.input1.className=&quot;inputStyleName&quot;;
in order to add a certain class to all inputs in my form, for exp to:
<INPUT type=&quot;text&quot;>

I don't want to assign the className to the input in the html part, like
<INPUT class=&quot;inputStyleName&quot; type=&quot;text&quot;>
because ns4 does not like it, (the class has properties like border and stuff).
I prefer not to write the whole form using document.write as well (regarding each browser)

I'd like that for IE and ns6.

Any suggestions?
Thanks in advance
 
Forget it, I solved it:

I inserted the <style> tags only when it's not ns4,and it's working great.
And now I have this style for all the inputs in the document.

<SCRIPT language=&quot;javascript&quot;>
if (!NS4)
{document.write(&quot;<STYLE type='text/css'>&quot;);
document.write(&quot;INPUT {etc.}&quot;);
document.write(&quot;</STYLE>&quot;);
}
</SCRIPT>

So happy I found the solution myself. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top