![]() |
|
|
|
#1 |
|
hey all,
i apologize for this repost, but can someone please help me with writing some javascript for my radiobuttonlist control. all i want to do is when the radiobuttonlist control is clicked is to populate a texbox on the same webform with the value that was selected. thanks, rodchar =?Utf-8?B?cm9kY2hhcg==?= |
|
|
|
|
#2 |
|
Posts: n/a
|
Here is a potential solution:
Copy this function to your page code: Function CreateRBLSelectorScript(ByVal r As RadioButtonList, _ ByVal t As TextBox) As String Dim js As String js = "var c=document.getElementsByTagName('INPUT');" _ & "for(var i=0;i<c.length;i++)" _ & "{if ((c[i].name=='" & r.UniqueID & "')&&(c[i].checked))" _ & "{document.getElementById('" & t.UniqueID & "').value= " _ & "c[i].value}}" Return js End Function In your page_load sub add this line: rbl.Attributes.Add("onclick", Me.CreateRBLSelectorScript(rbl, txt)) Replace all "rbl" references with the variable for your radiobuttonlist and replace all "txt" references with the variable for the destination textbox. Testing performed: - Browsers: IE 6, Opera 8.5, and Mozilla 1.04 - RadiobuttonList Table and Flow layouts - Single and multiple RadioButtonLists on a page - Two RadioButtonLists pointing to one textbox - Two RadioButtonLists pointing to their own textboxes Hope this resolves a long-outstanding issue for all. "=?Utf-8?B?cm9kY2hhcg==?=" <> wrote in news:A8E7B9DF-1AF0-4B41-8429-: > hey all, > > i apologize for this repost, but can someone please help me with writing > some javascript for my radiobuttonlist control. > > all i want to do is when the radiobuttonlist control is clicked is to > populate a texbox on the same webform with the value that was selected. > > thanks, > rodchar > cbDevelopment |
|