Click to See Complete Forum and Search --> : perl/cgi/javascript dropdown menu


samrado
07-15-2003, 12:51 PM
I have written a perl/cgi web script that has a drop down menu and text fields in it. My goal is, when the user clicks an item in the drop down menu, a variable will be created with the string value of the option selected(in the drop down list), then it will be recalled instantly without a submit button(simply by the click of the option) in the text field. I know I have to use Javascripting to do this, but I dont have a clue how. Im guess that I have to write the dropdown menu in Jscript, but Id rather not, I dont have any experience with javascripting and any help would be greatly apreciated.
Thanks!

Khalid Ali
07-15-2003, 01:09 PM
ummm...what????:D

samrado
07-15-2003, 01:20 PM
Basically I want to know how to declare a variable using javascript from a dropdown menu, then call it in my cgi script in a text field. For example if I select "saturn" from the dropdown menu, then I want "saturn to instantly apear in a text box. Hope that helps,

Khalid Ali
07-15-2003, 08:15 PM
That you can do but it will not get to CGI unless you submit the form...

Suppose you have a text field name t1

<input type="text" name="t1"/>

Now in the onchange event of the list box put something like this

onchange="document.formName.t1.value=this.options[this.selectedIndex].value;

where formName is the name of the form

samrado
07-17-2003, 01:27 PM
Thank you for your help,

there is a -onchange=>"name of javascript sub" that I put into my cgi dropdown list that calls the javascript sub. But one last question, is there a way to call a perl subroutine, from javascript?

Note: the perl subroutine lives in the same script as the javascript coding.

thanks,

Sam