Tails
05-07-2004, 06:33 AM
I wanted to make a script to change all submit buttons in a form into type="image". But for some reason IE is popping up with "This command is not supported." Mozilla isn't displaying the image, but it displays the form name as text (no, it doesn't recognize and display the alt text). Mozilla's DOM inspector acknowledges that I changed the input's type attribute to image, and there's no javascript errors detected in the console, but it's not displaying the image. Is there a problem with the script or are there limitations of setAttribute()?
for(i=0;i<document.forms[0].length;i++)
{
if(document.forms[0][i].getAttribute('type')=='submit')
{
document.forms[0][i].setAttribute('type','image')
document.forms[0][i].setAttribute('src','http://yoursiteurl.com/image.gif')
document.forms[0][i].setAttribute('alt','submit')
}
}
for(i=0;i<document.forms[0].length;i++)
{
if(document.forms[0][i].getAttribute('type')=='submit')
{
document.forms[0][i].setAttribute('type','image')
document.forms[0][i].setAttribute('src','http://yoursiteurl.com/image.gif')
document.forms[0][i].setAttribute('alt','submit')
}
}