javascript - Unable to get value of the property 'checked': object is null or undefined Error -
we have application below java script code giving error,
unable value of property check box
, need change below code in format <%=checkbox1.clientid%>. please change below code in format,
i have multiple lines of code below, because of need use predefined variable "crtlname"
var ctrlname="checkbox" if(document.getelementbyid(ctrlname + "1").checked) { document.getelementbyid(ctrlname + "table1").style.display ='inline'; }
i'm not going modify code you, instead here samples may solve question.
if didn't wrong. major question how use inline expression <%=checkbox1.clientid%> in javascript. can following
var checkbox1 = document.getelementbyid('<%= checkbox1.clientid %>'); secondly, mentioned controls generated dynamically means may need achieve variable.clientid in javascript area.
var checkbox2 = document.getelementbyid( '<%= ((checkbox)this.page.findcontrol(_checkboxid)).clientid %>'); then set _checkboxid in code-behind
public string _checkboxid; protected void page_load(object sender, eventargs e) { _checkboxid = "checkbox2"; } finally, compare solution above prefer using attribute selector
document.queryselectorall("input[id*=checkbox]:checked");
Comments
Post a Comment