/    Sign up×
Community /Pin to ProfileBookmark

how to loop the chain select box..

how to loop the form, so that there would be a multiple select boxes..
here is the problem if i loop the form only..

[img]http://i5.photobucket.com/albums/y174/dikoalam/example.png[/img]

the code..

[CODE]
<form action=”” method=”post” name=”form1″>
<select name=”college” id=”college” onChange=”selected(this.selectedIndex)”>
<option value=”0″ selected>Select college..</option>
<option value=”1″>Engineering</option>
<option value=”2″>Business Administration</option>
<option value=”3″>Arts and Science</option>
<option value=”4″>Fine Arts</option>
</select>
<select name=”course” id=”course”>
<option value=”0″ selected>Select course..</option>
</select>
</form>

<script type=”text/javascript”>

var colleges=document.form1.college
var courses1=document.form1.course

var course=new Array()

course[0]=[‘Select course..’]
course[1]=[‘CE’,’COE’,’EE’,’ECE’,’IE’,’ME’,’CS’,’IS’,’IT’]
course[2]=[‘BSA-CAS’,’BSA’,’BSBA-FM’,’BSBA-BEC’,’BSBA-MGE’,’BSBA-MKM’,’BSBA-MA’,’BSENT’]
course[3]=[‘AB-Comm Arts’,’Tourism’,’HRM’, ‘Sec. Mgt.’]
course[4]=[‘BFA’,’BFA-Int Design’,’BFA-Painting’,’BID’]

function selected(collgrp){
courses1.options.length=0
if(collgrp >= 0){

for(i=0; i<course[collgrp].length; i++){
courses1.options[courses1.options.length]=new Option(course[collgrp][i])
}
}
}

</script>[/CODE]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@PadonakAug 06.2010 — you want this?

[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>
<title>how to loop the chain select box</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
div#main{
text-align:center;
padding-top:100px;
}
-->
</style>
<script type="text/javascript">
<!--
var corz = [
['Select course..'],
['CE','COE','EE','ECE','IE','ME','CS','IS','IT'],
['BSA-CAS','BSA','BSBA-FM','BSBA-BEC','BSBA-MGE','BSBA-MKM','BSBA-MA','BSENT'],
['AB-Comm Arts','Tourism','HRM', 'Sec. Mgt.'],
['BFA','BFA-Int Design','BFA-Painting','BID']
];

function sel(collgrp){

var course = document.getElementById('course');
course.options.length = 0;
if(collgrp >= 0){
for(var i = 0; i < corz[collgrp].length; i++){
course.options[course.options.length] = new Option(corz[collgrp][i]);
}
}
}
//-->
</script>
</head>
<body>
<div id="main">
<form action="" method="post" name="form1">
<select name="college" id="college" onchange="sel(this.selectedIndex);this.blur();">
<option value="0" selected="selected">Select college..</option>
<option value="1">Engineering</option>
<option value="2">Business Administration</option>
<option value="3">Arts and Science</option>
<option value="4">Fine Arts</option>
</select>

<select name="course" id="course"><option value="0" selected="selected">Select course..</option></select>

</form>
</div>
</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@pchsmvpauthorAug 07.2010 — i want to have an output like this sir...

[IMG]http://i5.photobucket.com/albums/y174/dikoalam/loops.jpg[/IMG]

thanks for the help..?
Copy linkTweet thisAlerts:
@JMRKERAug 07.2010 — i want to have an output like this sir...

[IMG]http://i5.photobucket.com/albums/y174/dikoalam/loops.jpg[/IMG]

thanks for the help..?[/QUOTE]


What's wrong with 'Podanak's solution? ?

If you really want it to look like your '.jpg', you will need to define

more of the selections than you have provided. :eek:

For example, how many selections under "Arts and Science" and what are the selections to display for each of those options?

Perhaps 'Podanak' is better at mind reading than I am ?
Copy linkTweet thisAlerts:
@PadonakAug 08.2010 — [B]pchsmvp[/B] i can't understand clearly what is really needed to be done my english is not that good..

anyway you can take this example and modify it the way you need. if not may be it would be better to make your page less interactive ?
×

Success!

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