The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Drop Down Menu problem
jarar
post Aug 29 2009, 01:28 AM
Post #1





Group: Members
Posts: 3
Joined: 29-August 09
Member No.: 9,611



I'm trying to setup a drop down menu that when submitted it takes user to a new url, but within the same window. See my current code below. Note: This code takes users to the url, but it open up a new window. I want it to go to the url within the same window.

-------
<script>function goToNewPage(dropdownlist) { var url = dropdownlist.options(dropdownlist.selectedIndex).value; if (url != "") { window.open(url); } }</script>
-------

<form style="margin-bottom:0;" name="dropdown" >
<select name="list" accesskey="E">
<option selected="selected">Please select a state</option>
<option value="sorry.html">Alabama</option>
<option value="sorry.html">Arizona</option>
<option value="sorry.html">Arkansas</option>
</select>
input type="image" src="images/WeShopDlvr_selectbtn2.jpg" width="38" height="39" align="left" onclick="goToNewPage(document.dropdown.list)" />

Any help would be appreciated
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 29 2009, 03:11 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Because window.open() opens a new window. Use 'window.location.href = url;' .
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jarar
post Aug 29 2009, 09:27 AM
Post #3





Group: Members
Posts: 3
Joined: 29-August 09
Member No.: 9,611



QUOTE(pandy @ Aug 29 2009, 04:11 AM) *

Because window.open() opens a new window. Use 'window.location.href = url;' .


Hi Pandy,

I'm a newb when it comes to this and appreciate your help. I'm still doing something wrong. Here is the script. I used your suggestion, but I must have placed it incorrectly.

<script>function goToNewPage(dropdownlist) { var url = dropdownlist.options(dropdownlist.selectedIndex).value; if (url != "") { window.location.href = url; } }</script>

I'm obviously missing something.

-J

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 29 2009, 03:26 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Yar, the bit in BODY is wrong. Did it really work at all before?

I found a page for you with detailed explanations. smile.gif
http://www.pageresource.com/jscript/jdropbox.htm

P.S. SCRIPT should have a 'type' attribute. It isn't crucial, but it's nice. happy.gif
http://htmlhelp.com/reference/html40/special/script.html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jarar
post Aug 29 2009, 09:07 PM
Post #5





Group: Members
Posts: 3
Joined: 29-August 09
Member No.: 9,611



QUOTE(pandy @ Aug 29 2009, 04:26 PM) *

Yar, the bit in BODY is wrong. Did it really work at all before?

I found a page for you with detailed explanations. smile.gif
http://www.pageresource.com/jscript/jdropbox.htm

P.S. SCRIPT should have a 'type' attribute. It isn't crucial, but it's nice. happy.gif
http://htmlhelp.com/reference/html40/special/script.html


Thank you so much, it works great. Unfortunately, I needed a custom image for the button and it doesn't allow that, unless I modify the code. I can deal with the code provided and the default "go" button. Unless you know how to modify it to allow a custom image. I have searched and searched online and the only think I can find is to replace the ---> input type="button" name="go" WITH---> input type="image" src="image.jpg" code, but it doesn't work with the script.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 05:02 AM