How to call a javascript function on selected index changes in a RadioButtonList?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ameetijantakar
    New Member
    • Feb 2008
    • 4

    #1

    How to call a javascript function on selected index changes in a RadioButtonList?

    Hi,

    I want to call a javascript function in attributes property of a RadioButtonList control when user changes his selection
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    So you have an event and a method, where is the problem?

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by ameetijantakar
      Hi,

      I want to call a javascript function in attributes property of a RadioButtonList control when user changes his selection
      You're going to have to write the JavaScript function to handle the RadioButtonList Click event.

      Then you'll have to apply the JavaScript to each RadioButton in the list so that it doesn't post back.

      You can do this like:
      [code=vbnet]
      For Each li As ListItem In MyRadioButtonLi st.Items
      li.Attributes.A dd("onclick","j avascript:theJa vaScriptFunctio nName('"+li.Val ue+"');")
      Next
      [/code]

      In the above code I pass the value of the radio button to the JavaScript function so that the JavaScript function can do it's processing based on this value.


      -Frinny

      Comment

      Working...