LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perlscript doesn't read selected Pull-down Menu (https://www.linuxquestions.org/questions/programming-9/perlscript-doesnt-read-selected-pull-down-menu-173468/)

cccc 04-22-2004 05:38 PM

Perlscript doesn't read selected Pull-down Menu
 
hi

I have a simple HTML file with javascript:
Code:

<HTML>
<HEAD>
<TITLE>Filterlist Example</TITLE>
</HEAD>
<BODY>

<!-- Load the javascript code -->
<script TYPE="text/javascript" SRC="filterlist.js"></SCRIPT>
<H1></H1>
<FORM NAME="myform" ACTION="">

Filter:
<A HREF="javascript:myfilter.reset()" TITLE="Clear the filter">Clear</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^USA')" TITLE="Show items starting with USA">USA</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^AUS')" TITLE="Show items starting with AUS">AUS</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^CAN')" TITLE="Show items starting with CAN">CAN</A>&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT NAME=regexp onKeyUp="myfilter.set(this.value)">
<INPUT TYPE=button onClick="myfilter.set(this.form.regexp.value)" value="Filter">
<INPUT TYPE=button onClick="myfilter.reset();this.form.regexp.value=''" value="Clear">
<p>

<SELECT NAME="myselect" SIZE=1>
<OPTION></OPTION>
<OPTION>USA NEW YORK
<OPTION>USA LOS ANGELES
<OPTION>AUS SYDNEY
<OPTION>AUS BRISBANE
<OPTION>CAN TORONTO
<OPTION>CAN VANCOUVER

</SELECT>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<script TYPE="text/javascript">

<!--
var myfilter = new filterlist(document.myform.myselect);
//-->

</SCRIPT>
</p>
<P>
</FORM>
            <FORM action="/cgi-bin/show.pl" method="post">
            <input type="Submit" value="send">
</BODY>
</HTML>

I wrote a perl script to read and show on the browser the selected value from Pull-Down Menu,
but it doesn't read the value:
Code:

#!/usr/bin/perl

use CGI;
my $q = CGI->new();

foreach($q->param()){
  $FORM{$_} = $q->param($_);
}

print "content-type:text/html

<HTML>
  <HEAD>
  </HEAD>
  <BODY>
      $FORM{'myselect'};
  </BODY>
</HTML>;

I think the problem is on HTML file.
knows someone what's wrong ?

david_ross 04-23-2004 12:59 PM

You have 2 forms in your html and the submit button is in the second - there should only be one.

cccc 04-23-2004 02:26 PM

hi

and how to change the HTML, that JavaScript and Perl script are working independently of each other ?

kind regards
cccc

david_ross 04-23-2004 02:36 PM

Try:
Code:

<HTML>
<HEAD>
<TITLE>Filterlist Example</TITLE>
</HEAD>
<BODY>
<!-- Load the javascript code -->
<script TYPE="text/javascript" SRC="filterlist.js"></SCRIPT>

<FORM action="/cgi-bin/show.pl" method="post">

Filter:
<A HREF="javascript:myfilter.reset()" TITLE="Clear the filter">Clear</A>   
<A HREF="javascript:myfilter.set('^USA')" TITLE="Show items starting with USA">USA</A>   
<A HREF="javascript:myfilter.set('^AUS')" TITLE="Show items starting with AUS">AUS</A>   
<A HREF="javascript:myfilter.set('^CAN')" TITLE="Show items starting with CAN">CAN</A>   
<INPUT NAME=regexp onKeyUp="myfilter.set(this.value)">
<INPUT TYPE=button onClick="myfilter.set(this.form.regexp.value)" value="Filter">
<INPUT TYPE=button onClick="myfilter.reset();this.form.regexp.value=''" value="Clear">

<SELECT NAME="myselect" SIZE=1>
<OPTION></OPTION>
<OPTION>USA NEW YORK</OPTION>
<OPTION>USA LOS ANGELES</OPTION>
<OPTION>AUS SYDNEY</OPTION>
<OPTION>AUS BRISBANE</OPTION>
<OPTION>CAN TORONTO</OPTION>
<OPTION>CAN VANCOUVER</OPTION>
</SELECT>
<input type="Submit" value="send">               
<script TYPE="text/javascript">
<!--
var myfilter = new filterlist(document.myform.myselect);
//-->
</SCRIPT>
</FORM>
</BODY>
</HTML>


cccc 04-23-2004 03:51 PM

hi

Thanks, but If I try this HTML, then the JavaScript doesn't work anymore.

greetings
cccc

david_ross 04-23-2004 03:52 PM

The forum automatically changes "javascript" to "java script" - just remove the space.

cccc 04-23-2004 04:18 PM

perl works correctly now, but java script doesn't work

where exactly, should I remove the space ?

gizmo_thunder 04-23-2004 07:52 PM

<script TYPE="text/javascript" SRC="filterlist.js"></SCRIPT>
put that line in the head tag..!!
i mean in between <head> and </head> hope this helps

cccc 04-24-2004 02:38 PM

hi

I have tried, but still doesn't work.

my HTML:
Code:

<HTML>
<HEAD>
<TITLE>Filterlist Example</TITLE>
<SCRIPT TYPE="text/javascript" SRC="filterlist.js"></SCRIPT>
</HEAD>
<BODY>
<!-- Load the javascript code -->
<FORM NAME="myform" ACTION="">
Filter:
<A HREF="javascript:myfilter.reset()" TITLE="Clear the filter">Clear</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^USA')" TITLE="Show items starting with USA">USA</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^AUS')" TITLE="Show items starting with AUS">AUS</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^CAN')" TITLE="Show items starting with CAN">CAN</A>&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT NAME=regexp onKeyUp="myfilter.set(this.value)">
<INPUT TYPE=button onClick="myfilter.set(this.form.regexp.value)" value="Filter">
<INPUT TYPE=button onClick="myfilter.reset();this.form.regexp.value=''" value="Clear"><p>

<SELECT NAME="myselect" SIZE=1>
<OPTION>
<OPTION>AUS SYDNEY
<OPTION>AUS BRISBANE
<OPTION>CAN TORONTO
<OPTION>CAN VANCOUVER
<OPTION>USA NEW YORK
<OPTION>USA LOS ANGELES

</SELECT>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SCRIPT TYPE="text/javascript">

<!--
var myfilter = new filterlist(document.myform.myselect);
//-->

</SCRIPT>
</p>
<P>
</FORM>
            <FORM action="/cgi-bin/show.pl" method="post">
            <input type="Submit" value="send">
</BODY>
</HTML>


gizmo_thunder 04-25-2004 12:37 AM

sorry dude :( but i really could not figure out the problem..:(
may be if you gime the code of the filter.js ill' try to debug and
try it myself and tell you.

david_ross 04-25-2004 07:05 AM

What output do you get from the perl script? Is it just a blank page?

cccc 04-25-2004 09:22 AM

YES, it is...

cccc 05-27-2004 09:30 AM

hi

this one works well:
Code:

<HTML>
<HEAD>
<TITLE>Filterlist Example</TITLE>
<SCRIPT TYPE="text/javascript" SRC="filterlist.js"></SCRIPT>
</HEAD>
<BODY>
<!-- Load the javascript code -->

<FORM NAME="myform" action="/cgi-bin/show.pl" method="post">

Filter:
<A HREF="javascript:myfilter.reset()" TITLE="Clear the filter">Clear</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^USA')" TITLE="Show items starting with USA">USA</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^AUS')" TITLE="Show items starting with AUS">AUS</A>&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="javascript:myfilter.set('^CAN')" TITLE="Show items starting with CAN">CAN</A>&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT NAME=regexp onKeyUp="myfilter.set(this.value)" size="20">
<INPUT TYPE=button onClick="myfilter.set(this.form.regexp.value)" value="Filter">
<INPUT TYPE=button onClick="myfilter.reset();this.form.regexp.value=''" value="Clear"><BR><BR>

<SELECT NAME="myselect" SIZE=1>
<OPTION>
<OPTION>AUS SYDNEY
<OPTION>AUS BRISBANE
<OPTION>CAN TORONTO
<OPTION>CAN VANCOUVER
<OPTION>USA NEW YORK
<OPTION>USA LOS ANGELES
</SELECT><BR><BR>

<input type="Submit" value="send">

<SCRIPT TYPE="text/javascript">
<!--
var myfilter = new filterlist(document.myform.myselect);
//-->
</SCRIPT>
</BODY>
</HTML>



All times are GMT -5. The time now is 10:25 PM.