View Full Version : code for passing vars to a pop up

02-22-2003, 07:09 PM

it's a long story, but i'll try to make it brief...

i have a friend who has a html only site and i have helped him out with some cold fusion functions to make it a bit more effective. prob for me is my js is terrible. this is what i need to be able to do...

user on his site enters name and email address in newsletter sign up box (in the template and so is on every page). the action for this form is a page on my server which inserts the data into a database. i want to use cgi.http_referer to return the user to the same page they were on... so far so good.

if the user has not entered both fields, i want to pass a var back to the referering page that spawns a pop up and says 'error. blah blah'. if the entry is correct, i want to pass a var back that says 'you have been added....etc'.

soooooo - seems like what i need is:

1. what does the returning link look like, ie. "cgi.http_referer?var=Error. Both fields are required."

2. then an if statement wrapped around the pop up code that asks if the var exists to spawn the pop up, otherwise don't.

3. then, how do i output the var in the pop up.

seems like 1 and 3 are more of a syntax issue and 2 - i have this basic pop up code which seems to work fine...


function openpopup(){
var popurl="result.htm"



any help would be greatly appreciated.

02-22-2003, 10:40 PM
The onsubmit can be used to call a function and check for empty variables etc. You can then write a custom message in a popup or alert based on form field tests. Try something like this:

<script type="text/javascript">

function formValidate()
var validated = true;
if(!validate(document.forms.user.n, document.forms.user.e) )
validated = false;

return validated;

function validate(obj, obj2)
if( (obj.value.length > 0) && (obj2.value.length > 0) )
msg = "you have been added....etc";
return true;
msg = "error. Empty Fields(s)";
return false;


<form name="user" action="p.htm" method="get" onsubmit="return formValidate()">
Name: <input type="text" name="n" /><br />
Email: <input type="text" name="e" /><br />
<input type="submit" />


- Terry

02-24-2003, 03:39 PM
hi Terry,

now that's lateral thinking! took me a while to work out how this would solve ALL my problems... but i got it!

thanks for your thinking... i really appreciate it!