PDA

View Full Version : Help with a menu script?


Doc
12-11-2000, 06:47 PM
I'm having problems getting a drop down menu script to work properly. I'm pretty new at this aspect of webdesign. http://geekvillage.com/ubb/biggrin.gif

I've tried 2 different things and gotten two problems, but I need some help figuring out what the solution is.

its at http://www.profitstogo.com/test.htm

Can anyone tell me what's wrong? (in idiot terms)

thanks!

AK
12-11-2000, 07:13 PM
Impossible to say without access to the source codes.

icehouse
12-12-2000, 04:59 AM
It will work with IE, however with some versions of netscape you may need to add a 'go' or similar button afterwords for users to click on after they make a choice.

AK
12-12-2000, 05:17 AM
Ah - I see you have changed the menu script from CGI to JavaScript. Works like a charm (both NS and IE), but I guess you knew that already?

Doc
12-12-2000, 12:47 PM
I was trying something else for a moment

the reason it works is that I didn't make it myself http://geekvillage.com/ubb/biggrin.gif

ok...so I switched it back to the other type I was trying...the manual one with the button....

source code?

this?


<body>

<form method="POST" action="/cgi-bin/menujump.cgi">
<p><select size="1" name="D1">
<option selected value="Choose ONe">Choose ONe</option>
<option value="Allclicks">AllClicks</option>
</select><input type="submit" value="Submit" name="B1"></p>
</form>

</body>

</html>


the script I want to use is called menujump.cgi...it looks like this...

#!/usr/local/bin/perl
################################################## #############
# This is straight forward script you define text file #
# with the separated with the AND (@) sign #
# The first part will be the link...and the second part #
# would be the name #
# like this #
# http://www.yahoo.com@Yahoo #
# |__________________| |___| #
# | | | | #
# The link The Name #
# #
# And you would call this like this: #
# <!--#exec cgi="../cgi-bin/menujump.cgi" --> #
# #
# That is all to it. #
# #
# Do all you want with it.... http://geekvillage.com/ubb/wink.gif> #
# #
################################################## #############

if ($ENV{'QUERY_STRING'** =~ /jump/) { &jump; **
else { &menu; **
################################################## #############
# This is the section that reads the text file and puts #
# it in the option of pull down menu #
################################################## #############
sub menu {
unless (open(MYFILE, "menu.txt")) {
die ("cannot open input file file1\n");
**
# if the program gets this far, the file was
# opened successfully
print "Content-type: text/html", "\n\n";
$line = <MYFILE>;
($link_dest, $link_name) = split ("\@", $line);
print "<FORM METHOD=POST ACTION=\"http://www.profitstogo.com/cgi-bin/menujump.cgi?jump\">";
print "<select name=\"url\" size=\"1\">";
while ($line ne "") {
print "<option value=\"$link_dest\"\> $link_name";
$line = <MYFILE>;
($link_dest, $link_name) = split ("\@", $line);
**

print "</select><input type=\"Submit\" value=\"Take Me There\"></form>";
**
################################################## #############
# This is the section that does the jump #
# This section was borowed from the script jump.cgi that i got#
# from a guy on the newsgroups....if this is you who wrote #
# this script and don't want me to use it here please feel #
# free to send me mail jarekg28@hotmail.com and i'll take it #
# out.
################################################## #############
sub jump {
# Read in all the variables set by the form
&parse_form;
$gotourl = $FORM{'url'**;
print "Location: $gotourl\n\n";
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'**);
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name** = $value;
**
**
**

you define the variables in a txt file called menu.txt...I have it like this so far...
http://www.profitstogo.com@Choose ONe http://www.profitstogo.com/allclicks.htm@Allclicks

I hope that's what you were asking for....

Also....if I can do this without the script or an easier way...that's fine with me.... http://geekvillage.com/ubb/smile.gif...

AK
12-12-2000, 02:19 PM
Yes, it was the latter code I meant... The script works fine on my server, so the problem is not in the code.

I don't think you are using the exact code you provided though. If you were, the script's output (the source code you provided first) would be: <FORM METHOD=POST ACTION="http://www.profitstogo.com/cgi-bin/menujump.cgi?jump"><select name="url" size="1"><option value="http://www.profitstogo.com"> Choose ONe
<option value="http://www.profitstogo.com/allclicks.htm"> Allclicks </select><input type="Submit" value="Take Me There"></form>...but the code on your page looks, like you mentioned, like this: <form method="POST" action="/cgi-bin/menujump.cgi">
<p><select size="1" name="D1">
<option selected value="Choose ONe">Choose ONe</option>
<option value="Allclicks">AllClicks</option>
</select><input type="submit" value="Submit" name="B1"></p>
</form>Note the difference in the <FORM ACTION... URLs between the first an second code snippets, and also the different names in the SELECT tag ("url" and "D1" respectively). So, without access to the exact code you are using, It's very hard for me to help you solve the problem.

[This message has been edited by AK (edited 12-12-2000).]

Doc
12-12-2000, 04:09 PM
I'm getting the feeling I'm totally off!

Looks like I'm gonna have to break down and go do some reading... http://geekvillage.com/ubb/frown.gif


Thanks for helping me AK.

Doc
12-12-2000, 04:26 PM
well...i found something that does what I want, without my needing to understnad it completely...

check out http://www.profitstogo.com/new_page_1.htm

however, i now understand the importance of learning http://geekvillage.com/ubb/smile.gif....i'm gonna have to work on this stuff so it won't be a problem in the future...

Click Here!