/    Sign up×
Community /Pin to ProfileBookmark

link in dropdown menu not working

i have a dropdown menu that goes like this:

[code]<script language=”JavaScript” type=”text/JavaScript”>
<!–
<SCRIPT TYPE=”text/javascript”>
<!–
function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
{
if(mySel.form.target)myWin = parent[mySel.form.target];
else myWin = window;
if (! myWin) return true;
myWin.location = myVal;
}
return false;
}
//–>
</SCRIPT>

<FORM
ACTION=”../cgi-bin/redirect.pl”
METHOD=POST onSubmit=”return dropdown(this.gourl)”>
<div align=”center”>
<INPUT TYPE=SUBMIT VALUE=”Check”>
<select name=”select” size=”1″ style=”background-color:#E1D193″ onChange=”displaydesc(document.form1.select1, thetext1, ‘textcontainer1’)”>
<option value=”” selected>Choose A F2P Quest </option>
<option value=”Quests/BFK.htm”>Black Knight’s Fortress – 2</option>
</select>
</div>
</FORM> [/code]

but when i select “Black Knight’s Fortress – 2” and then click on check, it links to “file/…/cgi-bin/redirect.pl” instead of “file/…/quests/BFK.htm”

how come?? can anybody help me?

the htm file linked by the dropdown menu is located in a subfile in the file where the htm file containing the menu is… (crystal clear?)

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@NedalsOct 08.2005 — I don't understand what you are trying to do with the dropdown function. It looks like you are attempting to display the content in a different window.

Dealing solely with the problem you posted...
<i>
</i>&lt;script type="text/javascript"&gt;
&lt;!--
function dropdown() {
// Here to display form action only
// delete this function and the .....onsubmit="return dropdown() unless you use it for somthing else.
alert(document.forms[0].action);
return false;
}
//--&gt;
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;FORM ACTION="../cgi-bin/redirect.pl" METHOD=POST onSubmit="return dropdown()"&gt;
&lt;div align="center"&gt;
&lt;INPUT TYPE=SUBMIT VALUE="Check"&gt;
&lt;select name="select" size="1" style="background-color:#E1D193" onchange="this.form.action = this.value"&gt;
&lt;option value="../cgi-bin/redirect.pl" selected&gt;Choose A F2P Quest &lt;/option&gt;
&lt;option value="Quests/BFK.htm"&gt;Black Knight's Fortress - 2&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;
&lt;/FORM&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@fablebadauthorOct 08.2005 — it doesn't work. i copy the 2 codes in their respective sections and when i try the selection, a window popup saying something about my localhost.


another question, in javascript, how do i set the menu width, and can i align center the options of the menu? (how?)
Copy linkTweet thisAlerts:
@NedalsOct 08.2005 — The code I posted works but all it does is display the 'form action'. As I stated previously, I have no idea what you are trying to do with YOUR 'dropdown' function.

I assume you mean the <select> when you mention 'menu'

add width:200px or whatever to the style.

As far as I know, you cannot center the option text.
Copy linkTweet thisAlerts:
@fablebadauthorOct 08.2005 — thx for the width thing


ill explain the whole thing of my dropdown (i may have a completely wrong code...)

i want the user to scroll the menu, select the option, then click "check" then the wanted page displays in the same window, in place of the previous page with the menu.

is that clearer?? thanks already
Copy linkTweet thisAlerts:
@NedalsOct 08.2005 — ...wanted page displays in the same window, in place of the previous page with the menu.[/QUOTE]
Then use the HTML as I posted but REMOVE the onSubmit="return dropdown()" in the form tag and remove ALL the javascript from the <head> section and it will work as you state above. Pretty simple. ?

Let me explain...

.... onchange="this.form.action = this.value"

This bit of code will change the form 'action' setting it to the page defined by the 'selected' option value. Then, when you click 'Check', the submit event, the form will be posted to the 'action' page. No other coding required.
Copy linkTweet thisAlerts:
@fablebadauthorOct 08.2005 — THX it works!!!


another thing, when i put width:200px in the style thingy, it doesn't work...i already have a style tag for my menu background color.
Copy linkTweet thisAlerts:
@NedalsOct 08.2005 — you mean all that??:[/QUOTE]
Yes.
Copy linkTweet thisAlerts:
@fablebadauthorOct 08.2005 — nevermind, i left the code and it works anyway ? . i edited the post above, there is my other problem. can i have a background color AND a set width?
Copy linkTweet thisAlerts:
@NedalsOct 08.2005 — nevermind, i left the code and it works anyway ? . i edited the post above, there is my other problem. can i have a background color AND a set width?[/QUOTE]
1. The code's not needed. It just doesn't do anything if you leave it in.

2. Sure

style="width:200px; background-color:#E1D193"

[b]UPDATE[/b]

Don't forget the semicolon.

Please don't edit your post after you get a reply. It tends to destroy the flow of the thread. If you must edit the post, do it with an [b]update[/b] like this one.

for example:

In your edited post, add 'deleted block of javascript code';
Copy linkTweet thisAlerts:
@fablebadauthorOct 08.2005 — ohh so the magic trick is that --> ";" !! ? i had tried with a simple comma...

ok, i'll follow those editing rules !

thx again, you've been of great help!
×

Success!

Help @fablebad spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...