PDA

View Full Version : sending info to cgi script


hogtied
10-20-2002, 02:50 AM
Hello members,

Currently I have some infomation that is sent to a cgi script through the form's action. What ends up happening is that it loads a new page. I want to have a window that pops-up. So i thought maybe send the info to the cgi script through javascript and then do a window.open command. But I don't how to send the info to perl from java. this is what i have currently:

(A chopped up version)

<form name="frmNewsletter" method="GET" action="/cgi/newsletter.pl" onSubmit="return checkEmail()">
<input type="image" src="images/submitEmail.gif" alt="Submit" name="SubmitEmail">

<script language="JavaScript">
function checkEmail()
{
if (email == "")
{
//show error
//return to email textbox
return false;
}
else
{
if (user >= 3 && domain >= 7)
{
//process info to cgi script
//THIS IS WHERE I WOULD SEND THE INFO but don't know how and to still have it print to a file... I know i might have to change the perl script to do this. but hey whatever...
return true;
}
else
{
//show error
//return to email textbox
return false;
</script>

When I click on the submit it goes through java to validate email. If it passes then the email address is sent to a cgi script that print the email to a file. Then it goes to another page. A blank one because i haven't specified a redirect. But I don't want another page to load. I want it to be on the same page and just a pop-up that says thanks..

Any input would be appreciated.

Thanks,
Hogtied

Grizz2
10-25-2002, 08:51 AM
Hey Hogtied,
Nobody's answered this yet so I'll take a stab at it. One way I've seen this done is to use the window.open command to create the small window, write the entire form to the new window, then submit it from that new window. You can submit it automatically with javascript so your user doesn't have to submit twice. Usually the new window pops up and loads the redirect page so they don't actually see the form being submitted.
Grizz

frodo
10-25-2002, 11:33 AM
Here's a bit of code that might be useful to stick in your cgi-script....

### You know that once you click the submit button it generates a blank page..... What might be useful is getting the cgi-script to redirect the page back one (previous page)... then getting the cgi-script to open a popup box using a link to another HTML or cgi-script... in the following example the pop-up box calls a cgi-script.


For example....... in your perl script type for the output


print qq~
<script language="JavaScript">
<!--
javascript:history.go(-1);
open_window();

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}


function open_window(){
MM_openBrWindow('display_form.cgi?submit=viewlist&&list_id=4','download','scrollbars=yes,resizable=yes,width=650,height=600');
}


//-->
</script>
~;



The code probably will need tweeking, but give it a whirl...

Cormac.

hogtied
10-25-2002, 07:34 PM
Thanks guys

I'll give those a try