zebasdad
asked on
selectedindex in javascript for radio button
Why can't I access/set the SelectedIndex for a radio button in javascript?
var thisrb = document.getElementById("r bNewOrderT ype")
thisrb.SelectedIndex = 0;
var thisrb = document.getElementById("r
thisrb.SelectedIndex = 0;
ASKER
I have seen this in other posts... but it does nothing at all... no error... just does nothing.
Because the radio button is in a dialog box... I also tried the source ID with ... getElementById, but still no luck... I can access my text boxes using the same source ID method.
var radioList = document.getElementById("D ialogNewOr der_ctl00_ rbNewOrder Type");
for( var i=0; i < radioList.length; ++i)
{
if( radioList[i].checked)
{
alert("Checked item: " + radioList[i].value)
}
}
Because the radio button is in a dialog box... I also tried the source ID with ... getElementById, but still no luck... I can access my text boxes using the same source ID method.
var radioList = document.getElementById("D
for( var i=0; i < radioList.length; ++i)
{
if( radioList[i].checked)
{
alert("Checked item: " + radioList[i].value)
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help!!... I guess because it's inside a dialog box (Essential Objects)... I had to use the uniqueID (from the view source) in order to get your example working...
var radioList = document.getElementsByName ("DialogNe wOrder$ctl 00$rbNewOr derType");
var radioList = document.getElementsByName
var radioList = document.getElementsByTagN
for( var i=0; i < radioList.length; ++i)
{
if( radioList[i].checked)
{
alert("Checked item: " + radioList[i].value)
}
}
that will work if on your radio buttons you have name="rbNewOrderType"