/    Sign up×
Community /Pin to ProfileBookmark

newbie needs some help please

I am new to the whole JavaScript and after banging my head for 3 days decided to ask for some help. I am trying to use the selectedindex function with a drop down menu that takes you to another page when click. This is what I have and cannot figured it out. Any help would be appreciated.

function infoMenu(infoMenu) {
var moreInfoSelect=infoMenu.moreInfo.selectedIndex
var moreInfoUrl=infoMenu.moreInfo.options[moreInfoSelect].value+”.html”
window.location=moreInfoUrl
}

<form id=”infoMenu” name=”infoMenu” method=”post” action=””>
<div align=”left”>
<select name=”moreInfo” onchange=”infoMenu(this.form)”>
<option value=”lab9-1solution”>Select an item</option>
<option value=”lab9-1artgallery”>Art Gallery</option>
<option value=”lab9-1giftshop”>Gift Shop</option>
<option value=”lab9-1cafe”>Art’s Cafe</option>
</select>
</div>
</form>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ChilliBauthorApr 12.2010 — sorry for the title, I should of made myself familier with the posting rules first. I will be more careful in the future, Thanks
Copy linkTweet thisAlerts:
@ChilliBauthorApr 13.2010 — I finally figured it out and although this is probably easy for most here, I thought I would share the final code for any others out there like myself that may want to use it as an example.

[code=html]<script type="text/javascript">
<!--Hide from old browsers
function infoMenu(menuInfo) {
var menuSelect=menuInfo.moreInfo.selectedIndex
var menuUrl=menuInfo.moreInfo.options[menuSelect].value+".html"
window.location=menuUrl
}

//-->
</script>

<form id="menuInfo" name="menuInfo" method="post" action="">
<div align="left">
<select name="moreInfo" onchange="infoMenu(menuInfo)">
<option value="lab9-1solution">Select an item</option>
<option value="lab9-1artgallery">Art Gallery</option>
<option value="lab9-1giftshop">Gift Shop</option>
<option value="lab9-1cafe">Art's Cafe</option>
</select>
</div>
</form>[/code]
×

Success!

Help @ChilliB 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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