/    Sign up×
Community /Pin to ProfileBookmark

Hello… i dont know if it is possible to do what i want to do, but i hope it is hehe

I have this code…

[CODE]

<form name=”form1″ method=”get” action=””>

<select style=”width:180px;” name=”List” size=”10″>
<option value=”1″>A</option>
<option value=”2″>B</option>
<option value=”3″>C</option>
<option value=”4″>D</option>
</select>

<input type=”button” name=”button” value=”check” onClick=”switchDiv(javascript:document.form1.List.value);”>

[/CODE]

I have several <div> named as the values of my combo box, ie

[CODE]

<div id=”1″ style=”visibility:hidde;”></div>
<div id=”2″ style=”visibility:hidde;”></div>
<div id=”3″ style=”visibility:hidde;”></div>
<div id=”4″ style=”visibility:hidde;”></div>

[/CODE]

switchDiv(“<div name>”) make 1 of this layers visile accord on what the user has selected

Now i cant make it work because i odnt want to refresh the page evrey time the user make a selection on the list…

Any idae on how to do it? plz ermember i dont want to refresh teh page…

Thx a lot

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterNov 30.2005 — #1

style="visibility:hidde[color=blue]n[/color];"

#2

[url=http://www.w3.org/TR/1999/REC-html401-19991224/types.html#type-name]IDs cannot start with a number[/url]

#3
<i>
</i>&lt;input type="button" name="button" value="check" onclick="switchDiv(document.form1.List.value)"&gt;



<i>
</i>&lt;div id="div1" style="visibility:hidden;"&gt;contents&lt;/div&gt;
&lt;div id="div2" style="visibility:hidden;"&gt;contents&lt;/div&gt;
&lt;div id="div3" style="visibility:hidden;"&gt;contents&lt;/div&gt;
&lt;div id="div4" style="visibility:hidden;"&gt;contents&lt;/div&gt;
Copy linkTweet thisAlerts:
@UltimaterNov 30.2005 — And finally the function:
<i>
</i>&lt;script type="text/javascript"&gt;
function switchDIV(v){
var e=document.getElementById("div"+v);if(!e)return;
e.style.visibility="visibile";
}
&lt;/script&gt;
×

Success!

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