Solved

Perl and html

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

777 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