Presto-X Posted May 2, 2007 Share Posted May 2, 2007 Hello Guys I'm trying to use a checkbox to enabled/disabled a text field. Can any one offer some advice? This is the code I'm trying to use but it does not work <script type="text/javascript"> function calldate(){ if (document.forms['services'].calcheckbox.checked==true){ document.forms['services'].calldate.disabled=false; } } </script> <input name="calldate" type="text" disabled="true" value="<?php echo "$calldate"; ?>"> <label><input name="calcheckbox" onclick="calldate()" type="checkbox" /> Change Date</label> Link to comment https://forums.phpfreaks.com/topic/49597-solved-using-a-checkbox-to-enableddisabled-a-text-field/ Share on other sites More sharing options...
jitesh Posted May 2, 2007 Share Posted May 2, 2007 <script language="javascript"> function set(checkobj){ if(checkobj.checked){ document.getElementById('textb').disabled = true; //document.getElementById('textb').style.display = "none"; }else{ document.getElementById('textb').disabled = false; //document.getElementById('textb').style.display = ""; } } </script> <input type="checkbox" name="check" id="check" onclick="javascript:set(this)"/> <input type="text" name="textb" id="textb"/> Link to comment https://forums.phpfreaks.com/topic/49597-solved-using-a-checkbox-to-enableddisabled-a-text-field/#findComment-243186 Share on other sites More sharing options...
schme16 Posted May 2, 2007 Share Posted May 2, 2007 far be it my place to mention this, but this area is for php, and while i'm not certain but i think it might only allow for php code to be placed here Link to comment https://forums.phpfreaks.com/topic/49597-solved-using-a-checkbox-to-enableddisabled-a-text-field/#findComment-243279 Share on other sites More sharing options...
Presto-X Posted May 2, 2007 Author Share Posted May 2, 2007 Hey schme16 I'm using this code with php and php in inbeded in this code so :OP Hey Jitesh thanks for the help, I ended up changing to look like this and it worked great! thanks... <script language="javascript"> function set(checkobj){ if(checkobj.checked){ document.getElementById('calldate').disabled = false; //document.getElementById('calldate').style.display = ""; }else{ document.getElementById('calldate').disabled = true; //document.getElementById('calldate').style.display = "none"; } } </script> <input type="text" name="calldate" id="calldate" disabled="true" value="<?php echo "$calldate"; ?>"/><input type="checkbox" name="check" id="check" onclick="javascript:set(this)"/> Link to comment https://forums.phpfreaks.com/topic/49597-solved-using-a-checkbox-to-enableddisabled-a-text-field/#findComment-243399 Share on other sites More sharing options...
schme16 Posted May 2, 2007 Share Posted May 2, 2007 Thats kool, just thoguht i'd mention it is all, and like i said, far be it my place to say anything in the first place...i'm usualy the one posting out of place ( mostly due to have a million tabs open at once!) Link to comment https://forums.phpfreaks.com/topic/49597-solved-using-a-checkbox-to-enableddisabled-a-text-field/#findComment-243461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.