S
Steve
I have created an ASP.Net page that contains a RadioButtonList. I
want to access these radio buttons using Javascript. However when the
page renders, the application wraps the <input> tags inside a <span>
tag with the same name.
This makes the buttons difficult (if not impossible?) to access via
javascript. Any ideas? Am I trying to do mix two things that
Microsoft didn't intend to mix?
Code follows.
Thanks,
Steve
<script language=Javascript>
// The following does not work, since a span tag has no attribute
// named "value".
if (theForm.employeeIDType.value == "S")
{
// some code
}
</script>
<asp:radiobuttonlist id="employeeIDType" runat="server">
<asp:ListItem value="S" Selected=True>SSN</asp:ListItem>
<asp:ListItem value="G">Green Card</asp:ListItem>
</asp:radiobuttonlist>
This results in HTML as follows:
<span id="employeeIDType">
<input id="employeeIDType_0" type="radio" name="employeeIDType"
value="S" /><label for="employeeIDType_0">SSN</label>
<input id="employeeIDType_1" type="radio" name="employeeIDType"
value="G" /><label for="employeeIDType_1">Green Card</label>
</span>
want to access these radio buttons using Javascript. However when the
page renders, the application wraps the <input> tags inside a <span>
tag with the same name.
This makes the buttons difficult (if not impossible?) to access via
javascript. Any ideas? Am I trying to do mix two things that
Microsoft didn't intend to mix?
Code follows.
Thanks,
Steve
<script language=Javascript>
// The following does not work, since a span tag has no attribute
// named "value".
if (theForm.employeeIDType.value == "S")
{
// some code
}
</script>
<asp:radiobuttonlist id="employeeIDType" runat="server">
<asp:ListItem value="S" Selected=True>SSN</asp:ListItem>
<asp:ListItem value="G">Green Card</asp:ListItem>
</asp:radiobuttonlist>
This results in HTML as follows:
<span id="employeeIDType">
<input id="employeeIDType_0" type="radio" name="employeeIDType"
value="S" /><label for="employeeIDType_0">SSN</label>
<input id="employeeIDType_1" type="radio" name="employeeIDType"
value="G" /><label for="employeeIDType_1">Green Card</label>
</span>