setAttribute problem in IE

K

kiny

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
 
W

web.dev

kiny said:
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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top