/    Sign up×
Community /Pin to ProfileBookmark

Problem with form selector

I’m trying to make the second drop down list only display the locations from the selected parks. e.g selecting central park will only show places in central park.

I have been trying to make it work but I highly doubt my javascript is correct and i need help please.

[CODE]
<head>
<meta content=”text/html; charset=utf-8″ http-equiv=”Content-Type” />
<title>Untitled 1</title>
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function (){
$(“#area”).change(function() {
if ($(this).val() == “centralprk”) {
$(“#central”).show();
}else if{
($(this).val() == “eastprk”) {
$(“#east”).show();
}else{
$(“#west”).show();
}
});
});
</script>
</head>
<body>
<p>
Area: <select name=”area” id=”area”>
<option value=”selectarea”>Select an area</option>
<option value=”eastprk”>East Park</option>
<option value=”centralprk”>Central Park</option>
<option value=”westprk”>West Park</option>
</select> <br/> <br/>
Building: <select name=”building” id=”building”>
<option value=”any”>Any</option>
<option value=”ehb” id=”central”>Eddy Haribo</option>
<option value=”jfr” id=”central”>Jack Franco</option>
<option value=”lds” id=”east”>Long Dream Site</option>
<option value=”anp” id=”east”>Andy Peter</option>
<option value=”jpw” id=”west”>Joseph Power</option>
</select> <br/> <br/>
</p>

</body>
[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rootOct 26.2014 — 
  • 1. you are using JQuery which is a framework

  • 2. the HTML tags id="" have to be unique and no duplicates.

  • 3. you can find plenty of tutorials online on how to repopulate or populate an option field set.
  • ×

    Success!

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