By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

Is this the best way to point to different CGI scripts?

P: n/a
JR
Hi. I have a CGI script that will need to call itself an unknown
number of times, to add rows, run queries, etc. At the bottom of the
output that is produced by the script, there are four buttons. I need
one of the buttons to simply be a back button. I have this button
working fine. I need the second and fourth buttons to point to the
current CGI script, but I need the third button to point to a
different CGI script. I need the second, third and fourth buttons to
pass their respective scripts all data entered on the form.

My clients will be using the most recent versions of IE and Netscape.
Is below a workable method of doing this? I will not be able to
actually test this myself until tomorrow. I've looked at the FAQs,
and there are many ways of using <input type...> to point to different
CGI scripts with different buttons, but because I'm using hyperlink
images to call submit, I don't know that the answers I found apply to
this particular problem.

If this isn't a workable method, could someone please provide me with
some code that is workable? Unfortunatley, I'm not a JavaScript guru,
and this is the best up with which I could come (I also tried using
functions, changing the document directly with syntax found on the
FAQs, but to no avail).

Thanks much!

<html>
<head>
<link rel="stylesheet" href="myCSS.css">
<SCRIPT LANGUAGE = "JavaScript" src="myJS.js">
</SCRIPT>
</head>
<body bgcolor=#00CCFF>

<!-- Lots of CGI script code -->

<form name="form1" action="p1.cgi">
<input type="text" name="input">
<br><br>
<a href='javascript:history.back();'
onMouseover="b1.src='i1_on.gif';"
onMouseout="b1.src='i1_off.gif';">
<img SRC="i1_off.gif"></a>

<a href='javascript:document.form1.submit();'
onMouseover="b2.src='i2_on.gif';"
onMouseout="b2.src='i2_off.gif';">
<img SRC="i2_off.gif"></a>

<!-- Change the form location. Will this get the data
on the form, as well as change the location? -->
<a href='javascript: document.form1.action = "p2.cgi";
javascript:document.form1.submit();'
onMouseover="b3.src='i3_on.gif';"
onMouseout="b3.src='i3_off.gif';">
<img SRC="i3_off.gif"></a>

<!-- Change the form location back to its original location. -->
<a href='javascript: document.form1.action = "p1.cgi";
javascript:document.form1.submit();'
onMouseover="b4.src='i4_on.gif';"
onMouseout="b4.src='i4_off.gif';">
<img SRC="i4_off.gif"></a>

</form>
</body>
</html>
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ron
JR wrote:
Hi. I have a CGI script that will need to call itself an unknown
number of times, to add rows, run queries, etc. At the bottom of the
output that is produced by the script, there are four buttons. I need
one of the buttons to simply be a back button. I have this button
working fine. I need the second and fourth buttons to point to the
current CGI script, but I need the third button to point to a
different CGI script. I need the second, third and fourth buttons to
pass their respective scripts all data entered on the form.

My clients will be using the most recent versions of IE and Netscape.
Is below a workable method of doing this? I will not be able to
actually test this myself until tomorrow. I've looked at the FAQs,
and there are many ways of using <input type...> to point to different
CGI scripts with different buttons, but because I'm using hyperlink
images to call submit, I don't know that the answers I found apply to
this particular problem.

If this isn't a workable method, could someone please provide me with
some code that is workable? Unfortunatley, I'm not a JavaScript guru,
and this is the best up with which I could come (I also tried using
functions, changing the document directly with syntax found on the
FAQs, but to no avail).

Thanks much!

<html>
<head>
<link rel="stylesheet" href="myCSS.css">
<SCRIPT LANGUAGE = "JavaScript" src="myJS.js">
</SCRIPT>
</head>
<body bgcolor=#00CCFF>

<!-- Lots of CGI script code -->

<form name="form1" action="p1.cgi">
<input type="text" name="input">
<br><br>
<a href='javascript:history.back();'
onMouseover="b1.src='i1_on.gif';"
onMouseout="b1.src='i1_off.gif';">
<img SRC="i1_off.gif"></a>

<a href='javascript:document.form1.submit();'
onMouseover="b2.src='i2_on.gif';"
onMouseout="b2.src='i2_off.gif';">
<img SRC="i2_off.gif"></a>

<!-- Change the form location. Will this get the data
on the form, as well as change the location? -->
<a href='javascript: document.form1.action = "p2.cgi";
javascript:document.form1.submit();'
onMouseover="b3.src='i3_on.gif';"
onMouseout="b3.src='i3_off.gif';">
<img SRC="i3_off.gif"></a>

<!-- Change the form location back to its original location. -->
<a href='javascript: document.form1.action = "p1.cgi";
javascript:document.form1.submit();'
onMouseover="b4.src='i4_on.gif';"
onMouseout="b4.src='i4_off.gif';">
<img SRC="i4_off.gif"></a>

</form>
</body>
</html>

Alter to the following, some typos fixed and a default script type
registered in the header to aid the browser. The "language" attribute is
deprecated in favor of mimetype:

<?xml version="1.0"?>
<?xml-stylesheet href="myCSS.css" type="text/css"?>
<?xml-stylesheet href="#thisStyle" type="text/css"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<!-- IE does not support XML stylesheet PIs, and XHTML processors ignore stylesheet links -->
<link rel="stylesheet" href="myCSS.css" type="text/css" />
<script type="text/javascript" src="myJS.js">
</script>
<style id="thisStyle">
<![CDATA[
body {
background-color:#00CCFF
}
]]>
</style>
</head>
<body>

<!-- Lots of CGI script code -->

<form name="form1" action="p1.cgi">
<input type="text" name="input" />
<br /><br />
<a href="javascript:history.back();"
onmouseover="b1.src='i1_on.gif';"
onmouseout="b1.src='i1_off.gif';">
<img src="i1_off.gif" /></a>

<a href="javascript:document.form1.submit();"
onmouseover="b2.src='i2_on.gif';"
onmouseout="b2.src='i2_off.gif';">
<img src="i2_off.gif" /></a>

<!-- Change the form location. Will this get the data
on the form, as well as change the location? -->
<a href="javascript:document.form1.action = 'p2.cgi';document.form1.submit();"
onmouseover="b3.src='i3_on.gif';"
onmouseout="b3.src='i3_off.gif';">
<img src="i3_off.gif" /></a>

<!-- Change the form location back to its original location. -->
<a href="javascript:document.form1.action = 'p1.cgi';document.form1.submit();"
onmouseover="b4.src='i4_on.gif';"
onmouseout="b4.src='i4_off.gif';">
<img src="i4_off.gif" /></a>

</form>
</body>
</html>
Since your clients are using the most recent browsers, I've also updated
the markup to the latest standards. Otherwise, your code should work;
I've had to switch forms like this myself. :)
Jul 23 '05 #2

P: n/a
Thanks for the response and the modifications. I'm very relieved to
know that this method can actually work!

Joe


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.