Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Perl and html

Posted on 2011-03-20
2
Medium Priority
?
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
Jeffrey Dake earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

705 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