What is the best way to gray text in HTML form? I need the inputs to be grayed out when the user has checked the box. Should I use JavaScript for this (not very familiar with JavaScript), or can I use PHP (with which I am more familiar)?
EDIT:
After some reading, I have some code, but this gives me problems. For some reason, I cannot get my script to work based on the input state of the form (enabled or disabled) or the state of my checkbox (checked or not checked), but my script works fine when I base it on the input values of the form. I wrote my code just like a few examples on the Internet (mainly this one ), but to no avail. None of the materials that are commented will work. What am I doing wrong here?
<label>Mailing address same as residental address</label>
<input name="checkbox" onclick="disable_enable()" type="checkbox" style="width:15px"/><br/><br/>
<script type="text/javascript">
function disable_enable(){
if (document.form.mail_street_address.value==1)
document.form.mail_street_address.value=0;
else
document.form.mail_street_address.value=1;
}
</script>
EDIT:
Here is the updated code based on what @ Chief17 suggested. The best I can say is none of this works. I use valueas a test because it works for some reason
<label>Mailing address same as residental address</label>
<input name="checkbox" onclick="disable_enable()" type="checkbox" style="width:15px"/><br/><br/>
<script type="text/javascript">
function disable_enable(){
if (document.getElementById("mail_street_address").getAttribute("disabled")=="disabled")
document.form.mail_street_address.value=0;
//document.getElementById("mail_street_address").removeAttribute("disabled");
//document.getElementById("mail_city").removeAttribute("disabled");
//document.getElementById("mail_state").removeAttribute("disabled");
//document.getElementById("mail_zip").removeAttribute("disabled");
else
document.form.mail_street_address.value=1;
//document.getElementById("mail_street_address").setAttribute("disabled","disabled");
//document.getElementById("mail_city").setAttribute("disabled","disabled");
//document.getElementById("mail_state").setAttribute("disabled","disabled");
//document.getElementById("mail_zip").setAttribute("disabled","disabled");
}
</script>