View Full Version : Problems with One event handler, many actions

Jun 30th, 2002, 09:59 PM
Hi everyone,

I am new to programming and indeed javascript, though I have managed to pick up a few skills from a number of tutorials including tips from this Forum. Thanks to all.

However, I have come up against something that i must confess has drawn me to the battlefront. Half won, half lost.

Here's my dilema.

I am trying to write a code to help me achieve the following results.

1. I have one checkbox on a page which I want the user to check before they submit the page.

2. I would like the checkbox to be validated so that, the user will have to check it before they can proceed. If they do not, they will be reminded to do so, unless they chose to exit the page via an exit button.

3. On validating and successfully submitting the form, I would like a popup window to open and close itself whilst redirecting the parent window to a hidden redirect value in the popup.

Sounds complicated or confusing?

Well, I got it working in IE, but netscape is refusing to do both (ie; validate and open the popup window) It will do one or the other.

OK here's the breakdown and code

On the page with the checkbox, I've got:

In the head of the Main Page,

#<script language="Javascript">
#function validateForm() {
#var check_box = document.terms.check_box.checked;
#if (check_box == false) {
#alert("Please agree before continuing");
#return false;
#} else {
#return true;
#// -->

#var theURL = 'popuppage.html';
#var width = 200;
#var height = 100;
#function popRedirect() {
#newWindow = window.open(theURL,'newWindow','toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location= no,width='+width+',height='+height);

In the body of the popup window,


#<form action="javascript:popRedirect()" onSubmit="return validateForm()" method="get" name="terms" >
Please check this box to Accept : <input type="checkbox" name="check_box" value="terms">

#<input type="image" src="../../images/iagree2.gif" onSubmit="return validateForm(); popRedirect()" border="0" onMouseOver="window.status='Accept'; return true;" onMouseOut="return true;">

In the head of the PopUpPage,



#var browser_type=navigator.appName
#var browser_version=parseInt(navigator.appVersion)

#//if NS 4+
#if (browser_type=="Netscape"&&browser_version>=4)
#//if IE 4+&&browser_version>=4)
#else if (browser_type=="Microsoft Internet Explorer
#//Default goto page (NOT NS 4+ and NOT IE 4+)

#var Timer = 10000;
#t = null;
#function closeMe(){
#t = setTimeout("self.close()",Timer);

In the body of the popup window,

#<body onload="javascript:load('redirect_to_page.html',top.opener,top.close())"


If the above does not display properly, please see the attached txt. file.

Thanks to all who take the time to read and help.


Jun 30th, 2002, 10:21 PM
Please don't crosspost, wastes everybody's time. Ok? :)

I'll close this thread - for everyone else, please direct all replies too: