Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Retrieving value from HTML->Javascript->Perl

by Speedy (Monk)
on Jul 05, 2002 at 23:16 UTC ( [id://179761] : note . print w/replies, xml ) Need Help??


in reply to Retrieving value from HTML->Javascript->Perl

Perhaps the problem is in getting the value of "textBox" passed in the JavaScript function call.

Try reading the value in the JavaScript function rather than passing it. This also would give you the chance to test for no value or improperly formatted values being entered.

For example, in your HTML code, try something like:

<html> <head> <script language="JavaScript"> function priceList () { var text=form.textBox.value; win=window.open("/cgi-bin/getPrice.pl?textBox="+text,"","width=250,hei +ght=240") } </script> </head> <body> <form name='form'> <input type="text" name="textBox" size="8"> <a href="javascript:priceList();">Price List</a> </form> </body> </html>

with about the same Perl script, for example:

#!/usr/bin/perl use strict; use warnings; use CGI; my $q = new CGI; my $partNumber = $q->param('textBox'); print $q->header, $q->start_html; print $q->p("Part Number = $partNumber"); print $q->end_html;

The pop-up window then contains the value entered.

Speedy

Live in the moment