Solved

Perl and html

Posted on 2011-03-20
2
311 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
alert(innerHTML); 8 33
Asp in script 6 39
Javascript Urgent help (Need help to disable event handler) 8 45
Word, Excel, Access icons 4 17
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

820 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