Skip navigation
lyav18
Currently Being Moderated

How to clear or reset a combo box field

Sep 19, 2012 8:54 AM

I have a 2 combo boxes. The user selects a value for combo box 1, when the combo box 2 is selected I have a custom validation, in which I want the combo box 2 field to reset to default if the selected value is greater than the value in combo box 1. Here is the tested code:

 

if (event.value > this.getField("combo box 1").value) {

event.value = this.getField("combo box 2").defaultvalue;

this.getField("comb box 2").setFocus();

}

 

 

I've tried the following codes to try to reset the field, but none has worked:

this.resetForm("combo box 2");

this.getField("combo box 2").value = this.getField("combo box 2").default value;

event.value = " ";

event.value = "None";

(where " " is the value of the default)

(where None is the export value of the default value)

 

I tried this.getField("combo box 2").setItems(["value 1"]); which does work, but I would then have to put the entire list of options in. I'm not sure if this is the ideal approach. I was sure that there is a simple code for this simple problem., but I googled till my eyes hurt, and am out of ideas, does anyone have any other suggestions? Thanks.

 

Using Acrobat X Pro - Windows

 

~LV

 
Replies
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Sep 19, 2012 10:12 AM   in reply to lyav18

    I haven't tested it, but see if this works:

     

    if (+event.value > getField("combo box 1").value) {

        event.value = event.target.defaultvalue;

        event.target.setFocus();

    }

     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Sep 19, 2012 10:28 AM   in reply to George Johnson

    There was a typo in my code. It should be:

     

    event.value = event.target.defaultValue;

     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Sep 19, 2012 11:00 AM   in reply to lyav18

    That's weird, I'll have to look into that to see what's going on...

     

    The following doesn't reset, but it does reject the new value:

     

    if (+event.value > getField("cb1").value) {

        event.rc = false;

        event.target.setFocus();

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points