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!

show/hide fields problem

Status
Not open for further replies.

ajking

Technical User
Aug 13, 2002
229
0
0
I have set up a check box to show a hidden field when ticked. this works fine but if you then untick the box the field remains showing. How do I get the box to hide again? TIA
 
Try using a custom javascript like this:

var fieldToHide = this.getField("fieldToHide");

if (this.getField("fieldCheckbox").value == "Off")
{
// hide the field
fieldToHide.display = display.hidden;
}
else
{
fieldToHide.display = display.visible;
}

The only problem is that if the user enters data then unchecks and you hide the field, I think the data entered will still post. There is a way to reset the field that I'm looking into now, using this.resetForm(fieldnames);

My problem is I can't find how to list the field names - it's an array but you don't use this.getField. Any help on that would be appreciated.
Thanks.
 
Many Thanks. That worked a treat. If you find an answer to the field data clear could you post it to this thread. TIA
 
I found out how to empty out the setting and it's pretty simple - just use:

fieldToHide.value = "";

Also, FYI - you can create document level functions to call from any trigger from any field in your form. I noticed that a standard Reset button does not reset some things that I programatically change based on user selection. Therefore, I created functions that I can call from within the reset button to undo those changes.

Look under Tools > Javascripts > Document Javascripts to find where to put the document level functions.

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top