Solved

Perl and html

Posted on 2011-03-20
2
308 Views
Last Modified: 2012-06-27
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

0
Comment
Question by:bt707
2 Comments
 
LVL 10

Accepted Solution

by:
Jeffrey Dake earned 500 total points
ID: 35176012
Chances are there is something wrong with your document.update.emergencycontacts_declined_new.value="1"
that is throwing an error.

Are you sure the that the element represented by emergencycontacts_declined_new is in your document.  When I remove that one line, the script runs fine.  That would be the area you may want to investigate to see what is going on.
0
 

Author Closing Comment

by:bt707
ID: 35176026
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,
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now