Hi people

I have radio button list populated from database. By default first value is selected. How can i call JavaScript function if user selects another value in radio button list.

You can try this, is the first thing comes to my mind, in your Page_Load Method do this.

foreach(ListItem li in RadioButtonList1.Items)
{
   li.Attributes.Add("onClick", "CheckChange('" + li.Text + "','" + li.Value + "')");
}

Then just create a javascript function called CheckChange, li.text and li.value are parameters

Hope that helps!!!

Its still not calling function :( dun know why
kindly help me out...
its being two days that i m stuck here

Oh it works

I was so frustrated that i place your code before populating RadioButtonList

Very good piece of code.

Thank you jbisono

Cheers happy coding

anytime happy coding to you too!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.