Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Checkbox JavaScript's onClick to Hide/Show other input field?

Status
Not open for further replies.

markshen2004

Programmer
Jun 9, 2004
89
CA
I am doing a contact form (name, address,etc)
I want to use a checkbox to control other mail form hidden/show.

if address in contact form is same with address in mail form.I want to use checkbox checked to hidden the mail form.we only fill out contact form

if address in contact form isn't same with address in mail form.I want to use checkbox unchecked to show the mail form.we have to fill out two forms.

Please give me a idea how to do it.Thanks

Mark
 
Here is an example, it works for IE. Let me know if Netscape is an issue for you as well.

Code:
<html>
<head>
<script language="JavaScript">
<!--
function hideShow() {
	if (document.the_form.same_as.checked) {
		document.getElementById('mail').style.display = 'none';
	} else {
		document.getElementById('mail').style.display = 'inline';
	}
}
-->
</script>
<title>Test</title>
</head>
<body>
Please fill out your contact information:
<form name="the_form">
<div>
Name:<br><input type="text" name="c1"><br>
Address:<br><input type="text" name="c2"><br>
</div>
<p />
<div>
<input type="checkbox" name="same_as" onclick="hideShow();"> Check here if mailing address is the same as contact address.
</div>
<p />
<div style="display: inline;" id="mail">
Please enter your mailing information:<br>
Name:<br><input type="text" name="m1"><br>
Address:<br><input type="text" name="m2"><br>
</div>
</form>
</body>
</html>

*cLFlaVA
----------------------------
When will I be able to see what other members can see about myself? It's been like, a freakin' month already!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top