/    Sign up×
Community /Pin to ProfileBookmark

simple javascript drop down menu

I got this simple javascript but when i choose one of my options nothing displayed. Plz help, i don’t want to use show, hide functions. Is it possible to work just as it is?

<script>
// Show Hide
///////////////////////////
function show_what(id)
{
if (document.getElementById(id).style.display = “none”
{
document.getElementById(id).style.display = “none”;
}
else{
document.getElementById(id).style.display = “none”;
}
//////////////////////////////////////////////////////////////

// Select ChangeIt
///////////////////////////
function ChangeIt()
{
var aes
aes = document.getElementById().value ;

if (aes!=null)
{
if (aes==”ATHENS”)
{show_what(‘ATHENS’);}
else if (aes==”UK”)
{show_what(‘UK’);}
else if (aes==”GREEN”)
{show_what(‘GREEN’);}
}

}
//////////////////////////////////////////////////////////////
</script>

<select onChange=”ChangeIt()”>
<option value=””>Choose Location</option>
<option value=”ATHENS”>Athens</option>
<option value=”UK”>United Kingdom</option>
<option value=”GREEN”>Greenwich</option>
</select>

<br>

<div id=”ATHENS” style=”display:none;”>
<p><a name=”ATHENS”></a><b>Athens</b><br>qqqqqqqqqqqqqq</br></p>
</div>

<div id=”UK” style=”display:none;”>
<p><a name=”UK”></a><b>United- Kingdom</b></p>
wwwwwwwwwwwwww
</div>

<div id=”GREEN” style=”display:none;”>
<p><a name=”GREEN”></a><b>Greenwich</b></p>
ssssssssssssssssssssssss

</select>
</div>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJun 12.2009 — Depends on your definition of "work". ?
<i>
</i>&lt;script&gt;
function show_what(id) {
if (document.getElementById(id).style.display = "none")
{document.getElementById(id).style.display = "block";}
else
{document.getElementById(id).style.display = "none";}
}

function ChangeIt(it) {
aes = it.options[it.selectedIndex].value;
if (aes != "")
{show_what(aes);}
}
&lt;/script&gt;

&lt;form&gt;
&lt;select onChange="ChangeIt(this)"&gt;
&lt;option value=""&gt;Choose Location&lt;/option&gt;
&lt;option value="ATHENS"&gt;Athens&lt;/option&gt;
&lt;option value="UK"&gt;United Kingdom&lt;/option&gt;
&lt;option value="GREEN"&gt;Greenwich&lt;/option&gt;
&lt;/select&gt;
&lt;/form&gt;

&lt;br&gt;

&lt;div id="ATHENS" style="display:none;"&gt;
&lt;p&gt;&lt;a name="ATHENS"&gt;&lt;/a&gt;&lt;b&gt;Athens&lt;/b&gt;&lt;br&gt;qqqqqqqqqqqqqq&lt;/br&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;div id="UK" style="display:none;"&gt;
&lt;p&gt;&lt;a name="UK"&gt;&lt;/a&gt;&lt;b&gt;United- Kingdom&lt;/b&gt;&lt;/p&gt;
wwwwwwwwwwwwww
&lt;/div&gt;

&lt;div id="GREEN" style="display:none;"&gt;
&lt;p&gt;&lt;a name="GREEN"&gt;&lt;/a&gt;&lt;b&gt;Greenwich&lt;/b&gt;&lt;/p&gt;
ssssssssssssssssssssssss

&lt;/div&gt;
I have corrected the coding errors. I suspect it won't do exactly what you wanted, but maybe having it do something rather than nothing will inspire you to great things.
×

Success!

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