/    Sign up×
Community /Pin to ProfileBookmark

control list drop content

I want to limit the content from appear in list drop box.. for example, i select the europe location in the first list drop and i want only europe country to appear in the second list drop.. can u giv the coding example… please help me…?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@iokosanFeb 14.2009 — Here it is ?
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;select id='first' onchange='choice(this)'&gt;
&lt;option value='0'&gt;-&lt;/option&gt;
&lt;option value='1'&gt;a&lt;/option&gt;
&lt;option value='2'&gt;b&lt;/option&gt;
&lt;/select&gt;
&lt;select id='second'&gt;
&lt;/select&gt;
&lt;script&gt;
function choice(t){
var a = [1,2,3];
var b = [4,5,6,7];
s = document.getElementById('second');
var sl = s.options.length;
for(var i = sl-1; i &gt;= 0 ; i--)
s.options[i] = null;
if(t.value != 0){
var c = (t.value == 1)? a : b;
var l = c.length;
for(i = 0; i &lt; l; i++ )
s.options[i] = new Option(c[i],c[i],false,false);
}

}

&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@azielaauthorFeb 16.2009 — thanx iokosan... your coding is very helpful.. but how if the data is in the database??

it is still use the same method?
Copy linkTweet thisAlerts:
@iokosanFeb 20.2009 — you have 2 choices:

1) you make a xmlhttprequest to the server, who gives you a xml / json object that substitute the array

2) you create the page dinamicaly, and fill the various array with a for cycle using php.
×

Success!

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