Forum Moderators: open

Message Too Old, No Replies

Open new window and run cgi script

How do you open a new windows with a submit button and run a cgi script.

         

brotherjason

6:16 pm on Jul 22, 2003 (gmt 0)

10+ Year Member



I have been trying to get a new window to open while running a cgi script to populate the new window with data from my database.

I am using a cgi program called cgi-exec which allows you to use a hidden INPUT field with the name REF_DOC and a value for a script. It then does blackbox switching and can be used to run shell scripts to parse the data.

However, when I open the new window it runs the script but none of the data from the form for the hidden fields get passed. Thanks!

Here is the code for my form:

<form method="post" style="margin-bottom:0" action="/cgi-bin/cgi-exec.cgi">
<input type=hidden name=REF_DOC value=edit_entry.html>
<input type=hidden name=acl_entry value="test:user">
<input type="image" src="/images/edit_button.gif" height="19" width="47" border=0 alt="Edit Entry" onClick="window.open('/cgi-bin/cgi-exec.cgi','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=350,height=300'); return false;">
</form>

claus

6:49 pm on Jul 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi brotherjason, welcome to WebmasterWorld :)

I hope i did understand you, correct me if i'm wrong:

  1. Your user clicks the button
  2. The new window opens
  3. REF_DOC and acl_entry get sent to the CGI
  4. Results are displayed on the original page
  5. There are no results displayed in the popup

If this is the situation, it happens because you send the parameters in (3) off to the CGI from the calling page and not from the popup. In the popup you call the CGI without these parameters:

window.open('/cgi-bin/cgi-exec.cgi','',..')

If you want the results to display in the popup, you must call the CGI with the parameters from the popup. You are currently using a POST, so if you can change to a GET request, it will be quite easy to pass the parameters in the URL:

window.open('/cgi-bin/cgi-exec.cgi?REF_DOC=edit_entry.html&acl_entry=test:user','',..')

Hope this helps.

/claus

brotherjason

7:08 pm on Jul 22, 2003 (gmt 0)

10+ Year Member



Claus,

Thanks for the info. Unfortunatly I tried your suggestion and the program cgi-exec which I am using does not utilize command line input.

It may not be possible with the was I have it coded to send the values from the hidden INPUT fields to the cgi script and open a new window. But I haven't given up hope yet!

Thanks for your time!

Regards,
Jason

claus

7:50 pm on Jul 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah, i just read the manpage: [simtech-soft.com...]

- and also info on freshmeat that the commandline-option is defunct since 1.2.1. (i didn't mean commandline anyway). It should support both GET and POST though. I think this is the key (quote from manpage):

REF_DOC should be set as indicated above, with the value being the name of the referring HTML document.

An easy way to test is to change the POST you already have in your code to GET and then submit. In order to get the results to display in the popup window, you simply have to call it from a page that loads there. This can be done in a few ways, one example is javascript:

IN YOUR FORM:
--------------
window.open('/popup-page.html','',..')
--------------

IN NEW PAGE (called: popup-page.html)
--------------

<html>
<head>
<META HTTP-EQUIV="refresh" CONTENT="0;
URL="/cgi-bin/cgi-exec.cgi?REF_DOC=popup-page.html&acl_entry=test:user">
</head>
<body onLoad="javascript:window.location.href='/cgi-bin/cgi-exec.cgi?REF_DOC=popup-page.html&acl_entry=test:user'">

If you can see this text, please <a href="/cgi-bin/cgi-exec.cgi?REF_DOC=popup-page.html&acl_entry=test:user">click here to display results in stead</a>

</body></html>

--------------

There's three different calls to the CGI in this small html file, i believe at least one should do the trick.

/claus