/    Sign up×
Community /Pin to ProfileBookmark

Hello! Sorry to post another question.
I’ve got the following script, (i’ll post my problem below)…

in head:

<script>
function goUrl(formObj)
{
document.location.href = formObj.urlList[formObj.urlList.selectedIndex].value;
}
</script>

in body:

<form onsubmit=”goUrl(this); return false;”>
<div align=”center”><font color=”#000000″ size=”2″ face=”Tahoma”>Use these links:<strong> </strong></font>
<font color=”#000000″>
<select name=”urlList”>
<option value=”http://link.here”>FAQ</option>
<option value=”http://link.here”>Questionnaire</option>
</select>
</select>
<input name=”Submit” type=”Submit” value=”Go!”>

Problem is, when its just ONE drop-down menu with this, it works fine, when there’s two, neither work, it comes up with weird URL’s like …
[url]http://www.mysite.org/?select=http%3A%2F%2Fwww.mysite.org%2Fquestionnaire.html&Submit=Go%21[/url]

Any help is much appreciated, thanks !

Both have teh same <input name=”Submit” type=”Submit” value=”Go!”>

to post a comment
JavaScript

23 Comments(s)

Copy linkTweet thisAlerts:
@khakiApr 05.2003 — Hi skydan...

at first glance you have no closing tag for the form

</form>

and you have 2 closing </select> tags

it goes like this:

<form>

<select>

<option></option>

<option></option>

</select>

<input type="Submit">

</form>

try that first and see if it clears things up.

? k

[I]EDIT: oh... sorry... I just read your URL issue (oops).

give me a sec.....[/I]
Copy linkTweet thisAlerts:
@DanUKauthorApr 05.2003 — thanks ?
Copy linkTweet thisAlerts:
@khalidali63Apr 05.2003 — nothing looks wrong with your code at a glance,can you post the code for the second listbox as well that causes the problem,my guess is that you might have same name for both listboxes.

Cheers

Khalid
Copy linkTweet thisAlerts:
@DanUKauthorApr 05.2003 — i do ! Both are the same...they need to be sep?
Copy linkTweet thisAlerts:
@DanUKauthorApr 05.2003 — just tried,, put oen as submit the other as submit2, same prob ?
Copy linkTweet thisAlerts:
@khakiApr 05.2003 — :rolleyes: oh... there is a second set of drop-downs? :eek:

i can't read today, i guess :rolleyes:

yeah... like Kalid said... post the code for the other one too.

i need to go whip up something to eat real quick... but i'll look at it before i go out to see if i can help (although Kalid is very bored today - ? - so i'm going to guess that he will beat me to it. he's also much more brilliant than me... so your in better hands with him anyway. lol).

i'll check back in a bit.

k
Copy linkTweet thisAlerts:
@DanUKauthorApr 05.2003 — thanks. Yep two dropdowns..

code:

head:

<script>

function goUrl(formObj)

{

document.location.href = formObj.urlList[formObj.urlList.selectedIndex].value;

}

</script>

in body..

first menu:

<form onsubmit="goUrl(this); return false;">

<select name="select">

<option value="http://www.mysite.org/qa.html">Q&A</option>

<option value="http://www.mysite.org/questionnaire.html">Questionnaire</option>

</select>

<input name="Submit2" type="Submit" value="Go">

</form>

second:

<form onsubmit="goUrl(this); return false;">

<select name="urlList">

<option value="http://www.mysite.org/qa.html">Q&A</option>

<option value="http://www.mysite.org/questionnaire.html">Questionnaire</option>

</select>

<input name="Submit" type="Submit" value="Go">

</form>

Thanks
Copy linkTweet thisAlerts:
@khalidali63Apr 05.2003 — now you have to separate forms,and both do not have any name attribute assosciated with them,this is probably wrong.give them separate names and then try it.It will work.

Cheers

Khalid
Copy linkTweet thisAlerts:
@DanUKauthorApr 05.2003 — is that <form name="..."> ?
Copy linkTweet thisAlerts:
@khalidali63Apr 05.2003 — yes make it something like this

<form name="form1" onsubmit="goUrl(this); return false;">

and second one

<form name="form2" onsubmit="goUrl(this); return false;">

Khalid
Copy linkTweet thisAlerts:
@DanUKauthorApr 05.2003 — same ?
Copy linkTweet thisAlerts:
@DanUKauthorApr 06.2003 — now i've got ...

code:

head:

<script>

function goUrl(formObj)

{

document.location.href = formObj.urlList[formObj.urlList.selectedIndex].value;

}

</script>

in body..

first menu:

<form name="main" onsubmit="goUrl(this); return false;">

<select name="select">

<option value="http://www.mysite.org/qa.html">Q&A</option>

<option value="http://www.mysite.org/questionnaire.html">Questionnaire</option>

</select>

<input name="Submit2" type="Submit" value="Go">

</form>

second:

<form name="start" onsubmit="goUrl(this); return false;">

<select name="urlList">

<option value="http://www.mysite.org/qa.html">Q&A</option>

<option value="http://www.mysite.org/questionnaire.html">Questionnaire</option>

</select>

<input name="Submit" type="Submit" value="Go">

</form>

Thanks
Copy linkTweet thisAlerts:
@DanUKauthorApr 06.2003 — this is driving me insane ?

I don't understand what can be wrong with it ... thanks for all the previous help too.
Copy linkTweet thisAlerts:
@khakiApr 06.2003 — Good morning Daniel...

Sorry for not getting back to you... but it [I]was[/I] Saturday night... and I had to get ready to go out (it's a [I]girl thing[/I]... so don't bother trying to even understand it. lol)

Anyway... I'm up with the sun this morning (i'm so strange! lol), so better late than never.

I don't really understand the way that you have done it in your code (i couldn't get it to work either), but this is how I have done it in some of my pages that sorta follows the same idea.

(you'll notice no submit button... since it's not really needed and only adds an unnecessary step for the user)

See if this will work for you.

? k

(sleepy)

[SIZE=1]<html>

<head>



<script>

function goUrl(formSel)

{

SelPage = formSel.options[formSel.selectedIndex].value

if (SelPage != "")

{

window.location.href = SelPage

}

}

</script>



<body>



<form name="main">

<select name="select" onChange="goUrl(this.form.select)">

<option value="">Main Form Slections</option>

<option value="http://www.mysite.org/qa.html">Q&A</option>

<option value="http://www.mysite.org/questionnaire.html">Questionnaire</option>

</select>

</form>



<form name="start">

<select name="urlList" onChange="goUrl(this.form.urlList)">

<option value="">Start Form Slections</option>

<option value="http://www.mysite.org/qa.html">Q&A</option>

<option value="http://www.mysite.org/questionnaire.html">Questionnaire</option>

</select>

</form>



</body>

</html>[/SIZE]
Copy linkTweet thisAlerts:
@DanUKauthorApr 06.2003 — Thanks !!!!!!!!!
Copy linkTweet thisAlerts:
@DanUKauthorApr 07.2003 — Hey,

Can anyone tell me why the below isn't working? It doesn't seem to do anything ? thanks ...

Sorry for all the posts and thanks for all the previous help.

<script>

function goUrl(formSel)

{

SelPage = formSel.options[formSel.selectedIndex].value

if (SelPage != "")

{

window.location.href = SelPage

}

}

</script>

<body>

<form name="main">

<select name="select" onChange="goUrl(this.form.select)">

<option value="">Main Form Slections</option>

<option value="http://www.mysite.org/qa.html">Q&A</option>

<option value="http://www.mysite.org/questionnaire.html">Questionnaire</option>

</select>

</form>

<form name="start">

<select name="urlList" onChange="goUrl(this.form.urlList)">

<option value="">Start Form Slections</option>

<option value="http://www.mysite.org/qa.html">Q&A</option>

<option value="http://www.mysite.org/questionnaire.html">Questionnaire</option>

</select>

</form>
Copy linkTweet thisAlerts:
@pyroApr 07.2003 — It works for me in IE6. One thing that you should change, however, is the name of your first <select> box. You should never name a field with the same name as the field type.
Copy linkTweet thisAlerts:
@DanUKauthorApr 07.2003 — Ok done that (Thanks for the reply). When I try, In IE5, it just does nothing. I select the page but it just does nothing .. ? - Also when there's BOTH the drop-down menu's on one page, one works, but teh other (the main one) still does nothing ..
Copy linkTweet thisAlerts:
@DanUKauthorApr 07.2003 — I just tried also removing the 'second' list on the pages to see if the main one would work, but it didnt .. when you select something frmo the menu it doesnt load the page, it just does nothing .

I'm at a loss with this, any help you can give is much appreciated. Thanks.
Copy linkTweet thisAlerts:
@khalidali63Apr 07.2003 — Wholly ....is it still causing probs?...

I thought I gave you the solution yesterday.

Any ways here you go again.

http://68.145.35.86/temp/DoubleForm-skydan-Problem.html

The link points to the code I have tested with both NS6+ and IE6+

Hope this soolves it

Cheers

Khalid
Copy linkTweet thisAlerts:
@DanUKauthorApr 07.2003 — Great thanks !

Woohooo ?

Also, one last qu if i may. Is it possible with Javascript to show what IP a visitor is visitng from and their client? Just an aesthetic thing that I think would look cool hehe. Thanks fror all the help !
Copy linkTweet thisAlerts:
@DanUKauthorApr 07.2003 — I was just wondering, whether its possible to add with that Javascript that I asked above (about giving a visitors IP when they visit and their client version) whether its possible to add the current time too, for a more interactive view? Thanks
Copy linkTweet thisAlerts:
@khalidali63Apr 07.2003 — You can get the current time with JavaScript here is the syntax

var currentTime = new Date();

the above will return a complete string with date, time and zone etc.

For the IP address, JavaScript it self does not have the ability to do it,of course you can use Java to do that ,however,that will only work in NS browsers.

Cheers

Khalid
×

Success!

Help @DanUK 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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