Welcome to WebmasterWorld Guest from 54.145.13.215

Forum Moderators: open

Message Too Old, No Replies

Getting a radiobutton checked in IE

How?

     
6:49 am on Apr 15, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:May 11, 2003
posts:172
votes: 0


I have a script that selects a radio button according to certain preferences, like this:

function fillinprod(prev_value) {
for (i=0; i<document.form1.product.length; i++)
{
if (document.form1.product[i].value == prev_value )
{
document.form1.product[i].defaultChecked = true;
break;
}
else
{
document.form1.product[0].defaultChecked = true;
}
}
}

What it does is that if a previous product is selected (taken from a PHP script), it'll fill in that, else it'll default to the first product in the list. It works in Moz, but not in IE.

Anyone know how to do it?

11:46 am on Apr 15, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 27, 2002
posts:125
votes: 0


I think you need to use .checked rather then .defaultChecked. I believe defaultChecked is readonly will you can read/write the checked property.
11:59 am on Apr 15, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:May 11, 2003
posts:172
votes: 0


Hmm... Nope, won't work.

[Edit]Doh, sorry. It does work, I just wrote Checked instead of checked. Damn case-sensitive thingamajingies... =P

Ah well. Thanks for the help! :)[/edit]

1:27 pm on Apr 15, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 14, 2004
posts:1181
votes: 0


I believe:

document.form1.product[0].value

may be what you are looking for. Be aware your HTML tags must have values specified for the individual selections.