Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
04-22-2004, 05:38 PM
#1
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623
Rep:
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>
<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">
<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>
<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 ?
04-23-2004, 12:59 PM
#2
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
You have 2 forms in your html and the submit button is in the second - there should only be one.
04-23-2004, 02:26 PM
#3
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623
Original Poster
Rep:
hi
and how to change the HTML, that JavaScript and Perl script are working independently of each other ?
kind regards
cccc
04-23-2004, 02:36 PM
#4
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
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>
04-23-2004, 03:51 PM
#5
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623
Original Poster
Rep:
hi
Thanks, but If I try this HTML, then the JavaScript doesn't work anymore.
greetings
cccc
04-23-2004, 03:52 PM
#6
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
The forum automatically changes "javascript" to "java script" - just remove the space.
04-23-2004, 04:18 PM
#7
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623
Original Poster
Rep:
perl works correctly now, but java script doesn't work
where exactly, should I remove the space ?
Last edited by cccc; 04-23-2004 at 04:21 PM .
04-23-2004, 07:52 PM
#8
Member
Registered: Apr 2004
Posts: 101
Rep:
<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
04-24-2004, 02:38 PM
#9
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623
Original Poster
Rep:
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>
<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"><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>
<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>
04-25-2004, 12:37 AM
#10
Member
Registered: Apr 2004
Posts: 101
Rep:
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.
04-25-2004, 07:05 AM
#11
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
What output do you get from the perl script? Is it just a blank page?
04-25-2004, 09:22 AM
#12
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623
Original Poster
Rep:
YES, it is...
05-27-2004, 09:30 AM
#13
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623
Original Poster
Rep:
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>
<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)" 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 08:25 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News