0

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

4
Contributors
4
Replies
7
Views
6 Years
Discussion Span
Last Post by Hummdis
0

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.

0

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.

0

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'" />
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.