/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] dropdown list

I have the following dropdown:

[CODE]
<form method=’get’>
<select name=”List” id=”NYT”>
<option value=0>Hardback Fiction</option>
<option value=5>Paperback Non-Fiction</option>
<option value=6>Picture Books</option>
</select>
</form>
[/CODE]

I want to be able to have the user select one of the options and get the value of the option to use to determine a list to be displayed. This code goes in the sidebar of a webpage, so I DON’T want the page re-invoked. I can used php or javascript or any combination to accomplish what I need, I just don’t know how to get the value from the dropdown. I know I can keep it from invoking the page again with a javascript function.

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@FangFeb 16.2010 — &lt;select name="List" id="NYT" [COLOR="Blue"]onchange="alert(this.value);"[/COLOR]&gt;
Copy linkTweet thisAlerts:
@jackmasonauthorFeb 17.2010 — Thank you very much!
Copy linkTweet thisAlerts:
@jackmasonauthorFeb 17.2010 — Here is the entire file:
[CODE]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dropdown Test</title>
<script type=text/javascript">
function GetOption(Value, dropdown)
{ alert("New Value:" + Value + " and Index: " + dropdown.selectedIndex);

return false;
}
</script>
</head>
<body>
<form method='post' action='btest.php'> <!-- this page -->
<select name="List" id="NYT" onchange="GetOption(this.value, this.form.List)" >
<option value=0>Hardback Fiction</option>
<option value=1>Hardback Non-Fiction</option>
<option value=3>Paperback Fiction</option>
</select>
</form>
</body>
</html>[/CODE]


I thought I would at least get an alert message, but I get nothing!
Copy linkTweet thisAlerts:
@FangFeb 17.2010 — You forgot a quote: <script type=[COLOR="Red"]"[/COLOR]text/javascript">
Copy linkTweet thisAlerts:
@jackmasonauthorFeb 17.2010 — Never mind..... I found a missing double quote.... it does work fine.
×

Success!

Help @jackmason 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,
)...