Solved

pass a js variable to CGI

Posted on 2000-05-08
5
276 Views
Last Modified: 2013-12-25
I need a confirm window for the CGI, I want to use confirm() function in JS. How do I pass return value of confirm() to my cgi program? Can anybody give me a sample code please?

Thanks,
0
Comment
Question by:Embt
  • 2
  • 2
5 Comments
 

Expert Comment

by:hualian
ID: 2790720
this is html code
<FORM method="GET" action="mycgi.cgi" onsubmit="confirm_mesg()" ;>

<script language="JavaScript">
<!--
function confirm_mesg() {
confirm("do you really want post form?\n");
}
//-->
</script>


if you still have problem,please say.
My icq is 18634452
0
 

Author Comment

by:Embt
ID: 2793075
Thanks for response. My problem is I need to pass the result(which is true of false) of confirm() to my CGI program. how do I do this?
0
 
LVL 1

Accepted Solution

by:
lambda earned 50 total points
ID: 2795473
Try this

<script LANGUAGE="javascript">
function callIt ()
{
      val1 = confirm ("Yes or no?");
      document.frm1.action="http://your.domain.com/cgi-bin/j_test.cgi?value1=blah&value2="+val1;
      document.frm1.submit;
      return false;
}
</script>

:
:
<form name="frm1" onSubmit="callIt ()">
:
:
<input type="submit" name="btnSubmit" value="Click">
</form>

________________________________________________________________________________________________________________
0
 
LVL 1

Expert Comment

by:lambda
ID: 2795490
Change the form tag :

<form name="frm1" method="post" onSubmit="callIt ()">

0
 

Author Comment

by:Embt
ID: 2811086
sorry for the rejection.

I haven't tested out lambda's proposed answer, but it looks like works. so I'll give the credit to him/her
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to count occurrences of each item in an array.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now