Link to home
Start Free TrialLog in
Avatar of bt707
bt707Flag for United States of America

asked on

Perl and html

I have a CGI using perl, I have some html in a section I'm trying to update but not getting it to do what I need.

From the code below:

if (document.update.emergencycontacts_name1_new.value == "") is TRUE
then I get a popup box that shows the "Your have not set any emergency contact information"

If I select Cancel then I get my alert popup for the "Hit cancel" with is suppose to do.

The problem I have is I'm trying to set it so that if I select OK from the popup then I set a new value which will print out the popup of "Hit OK" for now so I know it's working.

What am I doing wrong where I do not get the alert of "Hit OK" but I do get the "Hit cancel" if I select cancel so I know it's reading the if (answer) code.

Thanks,

if ($user)
  {
    print << "VALIDATE1";
<script language=javascript>
function validateData() {
    if (document.update.emergencycontacts_name1_new.value == "") {
        var answer =confirm("Your have not set any emergency contact information")
        if (answer) {
          document.update.emergencycontacts_declined_new.value="1"
          alert("Hit OK");
          return true;
        } else {
          alert("Hit cancel");
          return false;
        }
    }
    else {
        alert("Your EC is set " + document.update.emergencycontacts_name1_new.value + "!");
        return true;
    }
}
</script>
VALIDATE1

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Dake
Jeffrey Dake
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bt707

ASKER

You are right, I guess I should of noticed that one, so still need to fix a few things but at least now I see what the problem was.

Thanks,