i need to make a checkbox, that if it is checked it reveals a text field
that the end user can put in an old invoice number, and that the data
gets sent to the php e-mail form that i already have set up.
Thanks -Eric
if ($('#checkboxID').is(':checked')) {
//show your text field here
}
I would set up your form with all the fields you want and then hide the ones that need some condition to be met before they are shown with css. For example
input[name=hiddenTextboxName] { display: none; }
then you can use the above code to show the textbox.
Okay thanks a lot man!
Post back if you get stuck
This is no way to defy or argue with the information already supplied. I wrote it... it works... so I thought I would paste it in.
Paste this code into blank file to see how it runs <!-- Written by Adam Khoury @ www.developphp.com -->
<html>
<head>
<script type="text/javascript" language="javascript">
function toggleField(field) {
var myTarget = document.getElementById(field);
if(myTarget.style.display == 'none'){
myTarget.style.display = 'block';
} else {
myTarget.style.display = 'none';
myTarget.value = '';
}
}
</script>
</head>
<body>
<input type="checkbox" onclick="javascript:toggleField('myTF');"/>
Give optional information
<input name="myTF" id="myTF" type="text" style="display:none;" />
</body>
</html>
Thanks a lot worm but i used Adams code and it works perfectly! Thanks both of you for taking the time to help me out :)
|