angel777 Posted March 25, 2008 Share Posted March 25, 2008 i tried as the below... but .. each time i click on the checkbox.. it din not appear at that second.. only appear when i click somewhere of the website.. what should i modify.. thanks <input type="checkbox" onchange="document.getElementById('submitter').disabled=''" > <INPUT class=button type=submit value=Sign Up name=submit id="submitter" disabled="disabled"> also,, after i unchecked the checkbox.. it did not disable back the button Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/ Share on other sites More sharing options...
ansarka Posted March 25, 2008 Share Posted March 25, 2008 try this <input type="checkbox" onclick="document.getElementById('submitter').disabled=''" > Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500261 Share on other sites More sharing options...
angel777 Posted March 25, 2008 Author Share Posted March 25, 2008 ohh.. great.. but how do i disable the button when unchecked again .. Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500269 Share on other sites More sharing options...
ansarka Posted March 25, 2008 Share Posted March 25, 2008 in onchange calla javascript function , Try below code [code] <input type="checkbox" name="chkBoxName" onclick="button_chk()'" > <script> function button_chk() { var formName = document.formname; if( formName.chkBoxName.checked == true ) { formName.submit.disabled=false; }else { formName.submit.disabled=true; } } </script> <form name='formname'> <input type="checkbox" name='chkBoxName' onclick="button_chk()" > <INPUT class=button type=submit value=Sign Up name=submit id="submitter" disabled="disabled"> </form> [/code] Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500278 Share on other sites More sharing options...
ansarka Posted March 25, 2008 Share Posted March 25, 2008 TRY this code <script> function button_chk() { var formName = document.formname; if( formName.chkBoxName.checked == true ) { formName.submit.disabled=false; }else { formName.submit.disabled=true; } } </script> <form name='formname'> <input type="checkbox" name='chkBoxName' onclick="button_chk()" > <INPUT class=button type=submit value=Sign Up name=submit id="submitter" disabled="disabled"> </form> Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500279 Share on other sites More sharing options...
lordfrikk Posted March 25, 2008 Share Posted March 25, 2008 Alright what about this? <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Test Page for JS</title> <script type="text/javascript"> //<![CDATA[ function toggle() { var el = document.getElementById('submitter'); el.disabled = (el.disabled == true) ? false : true; } // End of enable //]]> </script> </head> <body> <form action="testing.php" id="frm1" name="frm1"> <input type="checkbox" name="check1" onchange="toggle()" /> <input type="submit" name="submitter" id="submitter" value="Sign Up" disabled="disabled" /> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500286 Share on other sites More sharing options...
angel777 Posted March 25, 2008 Author Share Posted March 25, 2008 thanks ansarka ,lordfrikk however for ,lordfrikk code.. is working... .. when i click on checkbox.. the button enabled... but when i click on reset button.. the checkbox is unchekced.. but not for the button.. it remain enabled.. <INPUT class=button type=reset value=Reset name=submit> Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500299 Share on other sites More sharing options...
angel777 Posted March 25, 2008 Author Share Posted March 25, 2008 any idea ? Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500315 Share on other sites More sharing options...
lordfrikk Posted March 26, 2008 Share Posted March 26, 2008 Tried to change the reset button to reset the submit button but it didn't work Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500980 Share on other sites More sharing options...
zenag Posted March 26, 2008 Share Posted March 26, 2008 try this out.... <script type="text/javascript"> function clickme() { if(document.getElementById('zenag').checked==true) { document.getElementById('submitter').disabled=false; } else { document.getElementById('submitter').disabled=true; } } </script> </head> <body><input name="zenag" id="zenag" type="checkbox" onchange="" onclick="return clickme();" > <INPUT class=button type=submit value=Sign Up name=submit id="submitter" disabled="disabled"> <input type="button" value="Reload Page" onClick="window.location.reload()"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/#findComment-500982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.