Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - a little help please...

 
Thread Tools Search this Thread
Old 10-07-2005, 08:35 PM   #1
Default a little help please...


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==?=
  Reply With Quote
Old 11-13-2005, 08:56 PM   #2
cbDevelopment
 
Posts: n/a
Default Re: a little help please...
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46