OK, I am checking the values of a radiobuttonlist with 2 values (Yes
and No) using javascript:
<table id="optMedTreat ment"
onClick="SetFoc usDayPhone(docu ment.getElement sByName('optMed Treatment'))">
<tr>
<td><input id="optMedTreat ment_0" type="radio" name="optMedTre atment"
value="Yes" /><label for="optMedTrea tment_0">Yes</label></td>
</tr><tr>
<td><input id="optMedTreat ment_1" type="radio" name="optMedTre atment"
value="No" /><label for="optMedTrea tment_1">No</label></td>
</tr>
</table>
function SetFocusDayPhon e(e) {
var SelectedValue=" ";
var i=0;
for (i=0; i<=e.length; i++)
{
if (e[i].checked)
{
SelectedValue=e[i].value;
if (SelectedValue == "No")
{
alert("Hell Yeah");
break;
};
};
};
}
I am having 2 issues:
1. When I initially come to the page and check the No option I get the
Hell Yeah message. If I initially come in and check the Yes option I
don't get the message. The problem is that if I check No, get the
message, then check Yes, I still get the message. The javascript is
firing before the value has been changed. How do I get around this?
2. I am getting a error on my page when I check the yes option, this
does not happen when I check the No option as long as it is selected
first (i.e. if the yes is selected and then the No I still get the
error). Error Message is: 'checked' is null or not an object.
and No) using javascript:
<table id="optMedTreat ment"
onClick="SetFoc usDayPhone(docu ment.getElement sByName('optMed Treatment'))">
<tr>
<td><input id="optMedTreat ment_0" type="radio" name="optMedTre atment"
value="Yes" /><label for="optMedTrea tment_0">Yes</label></td>
</tr><tr>
<td><input id="optMedTreat ment_1" type="radio" name="optMedTre atment"
value="No" /><label for="optMedTrea tment_1">No</label></td>
</tr>
</table>
function SetFocusDayPhon e(e) {
var SelectedValue=" ";
var i=0;
for (i=0; i<=e.length; i++)
{
if (e[i].checked)
{
SelectedValue=e[i].value;
if (SelectedValue == "No")
{
alert("Hell Yeah");
break;
};
};
};
}
I am having 2 issues:
1. When I initially come to the page and check the No option I get the
Hell Yeah message. If I initially come in and check the Yes option I
don't get the message. The problem is that if I check No, get the
message, then check Yes, I still get the message. The javascript is
firing before the value has been changed. How do I get around this?
2. I am getting a error on my page when I check the yes option, this
does not happen when I check the No option as long as it is selected
first (i.e. if the yes is selected and then the No I still get the
error). Error Message is: 'checked' is null or not an object.
Comment