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..

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'" />
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.