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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make field hidden if another contains a value

Status
Not open for further replies.

slobad23

IS-IT--Management
Jun 30, 2006
90
GB
I have 2 fields on a form.

If the first field is populated with a value I would like the other field to be marked as hidden. Otherwise I want it to be visible to allow the user to populate it.

Ideally I would like this to happen when I tab out of the first field.

Could someone give me some pointers on how this would be done or if it's possible.

Many thanks.

(I did have a quick search on here to see if it had been asked before but turned up no results)
 
Hi

Code:
[b]<form[/b] [maroon]action[/maroon][teal]=[/teal][green][i]"#"[/i][/green][b]>[/b]
[b]<input[/b] [maroon]type[/maroon][teal]=[/teal][green][i]"text"[/i][/green] [maroon]name[/maroon][teal]=[/teal][green][i]"one"[/i][/green] [maroon]onchange[/maroon][teal]=[/teal][green][i]"this.form.two.style.visibility=this.value?'hidden':'visible'"[/i][/green][b]>[/b]
[b]<input[/b] [maroon]type[/maroon][teal]=[/teal][green][i]"text"[/i][/green] [maroon]name[/maroon][teal]=[/teal][green][i]"two"[/i][/green][b]>[/b]
[b]</form>[/b]
Note that you may have to set the visibility separately [tt]onload[/tt] for the case when the first [tt]input[/tt] keeps its previous value on refresh.


Feherke.
 
Thank you for your help! I also implemeted some code for onLoad which is working fine. Many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top