javascript - disable preselected checkbox -
i have these lines of code select checkbox based on preselected flag
if (objx.preselected) { string js = "if(document.getelementbyid('" + checkboxid + "').checked==false) document.getelementbyid('" + checkboxid + "').click();"; if (!page.clientscript.isstartupscriptregistered(checkboxid)) page.clientscript.registerstartupscript(this.gettype(), checkboxid, js, true); }
after done need disable preselected checkbox. tried below did not work
string js = "if(document.getelementbyid('" + checkboxid + "').checked==false) {document.getelementbyid('" + checkboxid + "').click();document.getelementbyid('" + checkboxid + "').disabled ='disabled';}";
update - disable checkbox problem it's not sent server. new asp.net programming, please suggest.any appreciated.
do need javascript? otherwise like:
if (objx.preselected) { checkbox.checked = true; checkbox.enabled = false; }
or
checkbox.checked = objx.preselected; checkbox.enabled = objx.preselected == false;
to make checkbox disabled using javascript can write
document.getelementbyid('id').disabled = 'disabled';
or
document.getelementbyid('id').disabled = true;
no need both .click() , .checked = true;
Comments
Post a Comment