Putting JavaScript Functions on RadioButtonList Items

  • Thread starter Thread starter Michael Schnell
  • Start date Start date
M

Michael Schnell

Is it possible to attach Javascript functions to individual
RadioButtonList Items? I've tried doing the Attributes.Add on the items
collections like so:

Me.Radiobuttonlist2.Items(0).Attributes.Add("onblur",
"DoPopupfrmDucted();")
Me.Radiobuttonlist2.Items(2).Attributes.Add("onblur",
"DoPopupfrmDucted();")
Me.Radiobuttonlist2.Items(1).Attributes.Add("onblur",
"DoPopupfrmFreeblow();")


But when I look at the source in the browser, they are never there.

Any help would be greatly appreciated.

Thanks,

Michael Schnell
 
I successully used an onclick event.

<asp:RadioButtonList Runat="server" ID="FileFormatList"
onclick="EnableDelimitedTextRadioButtonLists();">
.....asp list items...
</asp:RadioButtonList>

The rendered html actually puts the onclick on a table which radio
button list generates:
<table id="FileFormatList"
onclick="EnableDelimitedTextRadioButtonLists();" border="0">

The individual radio button controls are given the id of the
radiobuttonlist with _0, _1 etc appended.

<td><input id="FileFormatList_0" type="radio"
name="PoiExport:FileFormatList" value="Access2003" /><label
for="PoiExport_FileFormatList_0">Access® 2003 (XML)</label></td>

Knowing this naming convention (unfortunate necessity) you can find
the input controls with something like this:

var firstRadioButton = document.getElementById("FileFormatList_0");

which finds the first radio button.

Its value is:

firstRadioButton.checked
 
Back
Top