![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I need the SelectedValue of a radiobuttonlist in a Javascript variable. The radiobuttonlist is only used in a form for inputting data into a database. Before sending it to the database, i check the inputted values in Javascript. (By the way there is also a dropdownlist in the form, and i have no problem with getting its SelectedValue with the same javascript code). With the radiobuttonlist, i get "undefined" as value. Thanks for helping me Arnold The radiobuttonlist is created in the code-behind like this: Dim rb As RadioButtonList Dim frm As HtmlForm = Me.FindControl("form1") Dim rbl(2) As ListItem rb = New RadioButtonList rbl(1) = New ListItem("option 1", 1) rb.Items.Add(rbl(1)) rbl(2) = New ListItem("option 2", 2). rb.Items.Add(rbl(2)) rb.ID = "radio1" frm.Controls.Add(rb) The code in the aspx file: form id="form1" runat="server" input id="Sub1" type="button" value="submit" onclick="checkvalue()"/ /form script type="text/javascript" var antw function checkvalue() { antw=document.getElementById("radio1").value alert(antw) // this gives: undefined .... .... } /script |
#3
| |||
| |||
|
|
Hi, I need the SelectedValue of a radiobuttonlist in a Javascript variable. The radiobuttonlist is only used in a form for inputting data into a database. Before sending it to the database, i check the inputted values in Javascript. (By the way there is also a dropdownlist in the form, and i have no problem with getting its SelectedValue with the same javascript code). With the radiobuttonlist, i get "undefined" as value. Thanks for helping me Arnold |
|
The radiobuttonlist is created in the code-behind like this: Dim rb As RadioButtonList Dim frm As HtmlForm = Me.FindControl("form1") Dim rbl(2) As ListItem rb = New RadioButtonList rbl(1) = New ListItem("option 1", 1) rb.Items.Add(rbl(1)) rbl(2) = New ListItem("option 2", 2). rb.Items.Add(rbl(2)) rb.ID = "radio1" frm.Controls.Add(rb) The code in the aspx file: form id="form1" runat="server" input id="Sub1" type="button" value="submit" onclick="checkvalue()"/ /form script type="text/javascript" var antw function checkvalue() { antw=document.getElementById("radio1").value alert(antw) // this gives: undefined ..... ..... } /script |
#4
| |||
| |||
|
|
Hi, I need the SelectedValue of a radiobuttonlist in a Javascript variable. The radiobuttonlist is only used in a form for inputting data into a database. Before sending it to the database, i check the inputted values in Javascript. (By the way there is also a dropdownlist in the form, and i have no problem with getting its SelectedValue with the same javascript code). With the radiobuttonlist, i get "undefined" as value. Thanks for helping me Arnold The radiobuttonlist is created in the code-behind like this: Dim rb As RadioButtonList Dim frm As HtmlForm = Me.FindControl("form1") Dim rbl(2) As ListItem rb = New RadioButtonList rbl(1) = New ListItem("option 1", 1) rb.Items.Add(rbl(1)) rbl(2) = New ListItem("option 2", 2). rb.Items.Add(rbl(2)) rb.ID = "radio1" frm.Controls.Add(rb) The code in the aspx file: form id="form1" runat="server" input id="Sub1" type="button" value="submit" onclick="checkvalue()"/ /form script type="text/javascript" var antw function checkvalue() { antw=document.getElementById("radio1").value alert(antw) // this gives: undefined .... .... } /script |
#5
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |