Skip to main content
May 11, 2016
Question

Compare checkbox to numerical data and back

  • May 11, 2016
  • 1 reply
  • 303 views

Understand, I have no formal training or classes in javascript or programming on any level.  What minuscule amount I do know is based on what I've researched and managed to learn on my own, which means, I may need some hand holding.

The image is part of a form that military members use to request leave, this particular part addresses their method of travel, if they are doing so.  If they are traveling by a personally own vehicle(POV) they need to enter a distance they are traveling, if they are traveling, equal to or greater than 400 miles, they have to fill out an online form pertaining to how they are going to do this safely.

Amazingly, after a couple of hours, I manage to put together this, and it actually works:

var fldDistance = this.getField("txtDistance").value;

var cbPov = this.getField("grpTravelPOV");

var msg = "You must type distance you are traveling to continue";

if (this.getField("txtDistance").value == null || this.getField("txtDistance").value == "")

{

app.alert (msg); {

cbPov.value = "Off"; }

}

if (fldDistance >= 400) event.value = app.launchURL("https://trips.safety.army.mil/",true);

But I realized one small problem, a member can put in a number less than 400, say 350, check the POV box and everything is fine, as it should be.  But if they realize they put in the wrong distance and then changed it to 500, the above script is no longer in effect because it is tied to the checkbox, which is already checked, and they will not be redirected to the website.  Is there a way to tie in the distance so if they go back and change it, it redirects them?

This actually all started out using the distance field yesterday, when I realized I needed to make it tie into the POV checkbox, as this website is not required if they are traveling long distances by other means. So I got this far with the checkbox, but got burnt out thinking about this other issue.

While the script worked, and there were no errors, There may be a better way of doing this that is beyond what I discovered.

Thanks for any assistance.

This topic has been closed for replies.

1 reply

May 11, 2016

(ignore the CODE tags, that's not part of the script)

try67
Community Expert
Community Expert
May 12, 2016

You'll need to copy your code to the validation event of the text field,

with one minor modification.

Change this line:

var fldDistance = this.getField("txtDistance").value;

To:

var fldDistance = event.value;

On Thu, May 12, 2016 at 2:18 AM, DucatiItalia <forums_noreply@adobe.com>

May 12, 2016

So I did what you said, the result was I was always getting the warning message, so I did this:

[I guess I can't paste anything into here]

the checkboxes were not mutually exclusive and caused problems, which is why I added the other parameters.  the only real issue I have now, is if the POV is checked and the distance is changed from say, 300 to 500, then either click or tab out, it DOES NOT re-direct to the website.  However, it will re-direct if I click on the already 'checked' POV box.  With my little understanding, it's almost as if it loses focus, or doesn't validate subsequent changes to distance.