Perl  with java popup

Posted on 2011-04-22
Medium Priority
Last Modified: 2012-08-14
I have some Perl CGI pages where we use a few java pop ups, don't know much about java, I'm trying to add a check to a pop up but not getting what I want.

for example, I have a alert that pops up for this condition:

    if (document.forms[0].building_new.value != document.forms[0].building_orig.value) {
        alert("Please select a CITY xxxxx");
        return false;

This works fine as I can test it with does = or dose not =.

Problem I have is I need to check some other variables other than the building_new but I'm not getting any results, so does not look like they are even being defined as they should be but cannot tell.

For the example above, I know it's doing the compare but how can I print out the value of the building_new in my alert, I've tried to print "document.forms[0].building_new.value" but obviously that does not work, what is the format to print the value of:

I've seen examples such as using:  document.writeln  but I have not got it to work, I need to see how to print out what I'm looking at so I can figure out what is my problem with other checks I need to add.


Question by:bt707
  • 3
  • 2
LVL 86

Accepted Solution

CEHJ earned 2000 total points
ID: 35449766
Have you tried iterating document.forms[0].elements?

Author Comment

ID: 35449831
I'm sure I'm not doing it right as I'm just guessing, I don't know very little about java.

I tried putting in the alert to print

alert("Please select a CITY xxxxx document.forms[0].elements");

but that just print a pop up and the text of the pop up is:

Please select a CITY xxxxx document.forms[0].elements

I know that can't be right, but what do I need to do to print the elements, that would be good to have.

Author Comment

ID: 35449950
I did see what I was going wrong on part of it.

If I just use:


Then I do get the value of what's in building_new in my alert.

How can I do a loop to print out all of the values that is in document.forms ?

LVL 86

Expert Comment

ID: 35450158
>>How can I do a loop to print out all of the values that is in document.forms ?

By doing what i suggested at http:#35449766
LVL 86

Expert Comment

ID: 35453567

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

850 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