How to get a asp:radiobutton text in javascript?
I use this
RbDriver1.Text = dt.Rows[0].ItemArray[5].ToString();
RbDriver2.Text = dt.Rows[0].ItemArray[6].ToString() ;
and my javascript function is
function getDriverwireless() {
alert(document.getElementById("ctl00_ContentPlaceHolder1_RbDriver1"));
alert(document.getElementById("ctl00_ContentPlaceHolder1_RbDriver1").innerHTML);
}
innerHTML
doesnt seems to take the text of my radiobutton...any sugg开发者_Go百科estion
When i inspect throgh firebug i found this
<input type="radio" onclick="getDriverwireless();" value="RbDriver1"
name="ctl00$ContentPlaceHolder1$drivername"
id="ctl00_ContentPlaceHolder1_RbDriver1">
<label for="ctl00_ContentPlaceHolder1_RbDriver1">kamal,9566454564</label>
I want to get the value kamal,9566454564
in javascript...
Try to avoid using client ids in your js.
Regarding your question, the RadioButton control renders that html that you can see in firebug. using your approach of clientids:
document.getElementById("ctl00_ContentPlaceHolder1_RbDriver1").nextSibling.innerHTML
精彩评论