php - How to gray out HTML form inputs? -


What is the best way to shred text input on the HTML form? When a user checks the check box, I need brown inputs. Do I have to use Javascript for this (I'm not very familiar with Javascript) or can I use PHP (which I'm familiar with Do I?)

Edit:

After reading something, I got a little code, but it is giving me problems. For some reason, Enabled or disabled) or my checkbox status (check or uncheck), my script can not be found to work, but when I base it on the values ​​of the form, my script works fine. I have actually written my code online as many examples (primarily) but it has no benefit. None of the commented material will work. What am I doing wrong here?

  & lt; Label & gt; Mailing address as resident address & lt; / Label & gt; & Lt; Input name = "checkbox" onclick = "disable_enable ()" type = "checkbox" style = "width: 15px" /> gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Script type = "text / javascript" & gt; Function disable_enable () {if (document.form.mail_street_address.value == 1) document.form.mail_street_address.value = 0; //document.form.mail_street_address.disabled=true; //document.form.mail_city.disabled=true; //document.form.mail_state.disabled=true; //document.form.mail_zip.disabled=true; Else document.form.mail_street_address.value = 1; //document.form.mail_street.disabled=false; //document.form.mail_city.disabled=false; //document.form.mail_state.disabled=false; //document.form.mail_zip.disabled=false; } & Lt; / Script & gt;  

Edit:

Here's some updated code that suggested @ key 17. The best I can tell is that none of this is working. I am using value as a test because it works for some reason

  & lt; Label & gt; Mailing address as resident address & lt; / Label & gt; & Lt; Input name = "checkbox" onclick = "disable_enable ()" type = "checkbox" style = "width: 15px" /> gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Script type = "text / javascript" & gt; 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"""isisabled "); //document.getElementById("mail_city").setAttribute("disabled"""isisabled "); //document.getElementById(_mail_state").setAttribute("disabled"""isisabled "); //document.getElementById ("mail_zip").setAttribute("disabled"""isisabled "); } & Lt; / Script & gt;  

My other posts have been completely deleted and all the code you need Changed:

  & lt; Script type = "text / javascript" & gt; Function disable_enable () {if (document.getElementById ("checkbox") is checked! = 1) {document.getElementById ("Input 1"). Remove remove ("disabled"); Document.getElementById ("Input 2") removeAttribute ("disabled"). Document.getElementById ("Input 3") removeAttribute ("disabled"). Document.getElementById ("Input 4") removeAttribute ("disabled"). } And {document.getElementById ("Input 1"). SetAbbut ("disabled", "disabled"); Document.getElementById ("Input 2") setAttribute ("disabled", "disabled"). Document.getElementById ("Input 3") setAttribute ("disabled", "disabled"). Document.getElementById ("Input 4") setAttribute ("disabled", "disabled"). }} & Lt; / Script & gt;  

and

  & lt; Label & gt; Mailing address resident address is same as & lt; / Label & gt; & Lt; Input id = "checkbox" onClick = "disable_enable ()" type = "checkbox" style = "width: 15px" /> gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Input type = "text" id = "input1" /> & Lt; Input type = "text" id = "input2" /> & Lt; Input type = "text" id = "input3" /> & Lt; Input type = "text" id = "input4" />  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -