Compare checkbox to numerical data and back
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.
