Hi..
Please help me in creating a script that will show the hidden textbox if a checkbox is checked..
I don't have any idea on how to do this.
Thanks in advance..
Jump to PostCheck out Usable Forms.
I'm pretty sure you can find this code on the internet. The purpose of the DaniWeb Forum is to help people who are stuck with a programming problem and are not able to solve it. Try solving this problem yourself and if you get stuck, we are here to help you out. We will not however, do the code for you.
Here is a start...
Use Javascript to change the type attribute from hidden to text.
Here you go, This will show a Input[text] if you check the checkbox.
<script>
function validate(chk){
if (chk.checked == 1)
document.getElementById('Texttoshow').style.display="block";
else
alert("You didn't check it! Let me check it for you.")
chk.checked = 1;
}
</script>
<input type="text" value="hey" style="display:none"><input oncheck="validate(this.id)" type="check">
// It might not be oncheck im just guessing off top of my head.
s.gotactics, I'm pretty sure you mean well but your code will not work for 2 reasons.
1. You need to add in id="Texttoshow"
to the input field.
2. There is no onCheck event in JS, Use onclick.
Try this
<input type="hidden" value="x" id="x" name="x"/>
<input type="checkbox" onclick="document.getElementById('x').type='text'" />
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.
You're trying to visit a URL that doesn't currently exist on the web. Most likely, a member posted a link a long time ago to a web page that has since been removed. It's also possible that there was a typo when posting the URL. We redirect you to this notice instead of stripping out the link to preserve the integrity of the post.