homepage Welcome to WebmasterWorld Guest from 54.224.202.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Getting a radiobutton checked in IE
How?
Wertigon




msg:1481973
 6:49 am on Apr 15, 2004 (gmt 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?

 

HocusPocus




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

I think you need to use .checked rather then .defaultChecked. I believe defaultChecked is readonly will you can read/write the checked property.

Wertigon




msg:1481975
 11:59 am on Apr 15, 2004 (gmt 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]

Rambo Tribble




msg:1481976
 1:27 pm on Apr 15, 2004 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved