By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

setAttribute problem in IE

P: n/a
hi,
I am trying to create dynamic text fields with createElement. set it's
name,size with setAttribute. But every thing works fine with mozilla
browser and not in IE.

I read that IE doesn't support setAttribute.

I tried the following code

ele=document.form.createElement("<input name=test>");
ele.type='text';

can any body help me with this. I would like to create check box,
textbox and set many attribute for those.

thanks in advance

Sep 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

kiny wrote:
hi,
I am trying to create dynamic text fields with createElement. set it's
name,size with setAttribute. But every thing works fine with mozilla
browser and not in IE.

I read that IE doesn't support setAttribute.

I tried the following code

ele=document.form.createElement("<input name=test>");
ele.type='text';
What you probably meant to do was this:

var ele = document.createElement("INPUT");
ele.name = "test";
ele.type = "text"; //or radio or checkbox as you wish

Next, your question is somewhat ambiguous. Did you want to add your
newly created input to a form? If so then you can do the following:

html:

<form name = "myForm">
</form>

javascript:

document.forms["myForm"].appendChild(ele);

Sep 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.