/    Sign up×
Community /Pin to ProfileBookmark

two double drop-down menu help

i need to initialize these 2 double drop-down menu:

but works only first one, if i had only first i had no problem, but with 2 first one doesn’t work…
i hope i showed enought code.

[code=html]

<label>Model:</label>
<select name=”CarModelID” style=width:160px onchange=”advanced_search();”>
</select>
<script language=”javascript”>
<!–
// select the submitted brand
for (i=0;i<document.searcher.BrandID.options.length;i++) {
if (document.searcher.BrandID.options[i].value == ‘7’)
{
document.searcher.BrandID.options[i].selected=true;
break
}
}
//initialize status
chooseModel(document.searcher);
// select the submitted model
for (i=0;i<document.searcher.CarModelID.options.length;i++) {
if (document.searcher.CarModelID.options[i].value == ’76’)
{
document.searcher.CarModelID.options[i].selected=true;
break
}
}
–>
</script>

&nbsp; Model #2:
<select name=”CarModelID2″ style=width:155px>
</select>
<script language=”javascript”>
<!–
// select the submitted brand
for (i=0;i<document.searcher.BrandID2.options.length;i++) {
if (document.searcher.BrandID2.options[i].value == ‘9’)
{
document.searcher.BrandID2.options[i].selected=true;
break
}
}
//initialize status
chooseModel2(document.searcher);
// select the submitted model
for (i=0;i<document.searcher.CarModelID2.options.length;i++) {
if (document.searcher.CarModelID2.options[i].value == ’98’)
{
document.searcher.CarModelID2.options[i].selected=true;
break
}
}
–>
</script>

[/code]

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyNov 27.2008 — Nothing wrong in what you've posted. Just guessing, but I'd say the problem is probably in your [B]chooseModel2()[/B] function.
Copy linkTweet thisAlerts:
@miobauthorNov 27.2008 — here is rest

[code=html]function chooseModel(Obj){
clearModel(Obj);
ActualBrandID=Obj.BrandID.options[Obj.BrandID.selectedIndex].value;
eval('ActualArrayID=CarModelID'+ActualBrandID+';');
eval('ActualArrayName=CarModelName'+ActualBrandID+';');
for (a=0;a<ActualArrayID.length;a++){
Obj.CarModelID.options[a]=new Option(ActualArrayName[a],ActualArrayID[a]);
}

}

function clearModel(Obj){
for(a=Obj.CarModelID.length-1;a>-1;a--){
Obj.CarModelID.options[a]=null;
}
}

function chooseModel2(Obj){
clearModel2(Obj);
ActualBrandID2=Obj.BrandID2.options[Obj.BrandID2.selectedIndex].value;
eval('ActualArrayID2=CarModelID'+ActualBrandID2+';');
eval('ActualArrayName2=CarModelName'+ActualBrandID2+';');
for (a=0;a<ActualArrayID2.length;a++){
Obj.CarModelID2.options[a]=new Option(ActualArrayName2[a],ActualArrayID2[a]);
}
}

function clearModel2(Obj){
for(a=Obj.CarModelID2.length-1;a>-1;a--){
Obj.CarModelID2.options[a]=null;
}
}
[/code]
Copy linkTweet thisAlerts:
@MrNobodyNov 27.2008 — Perhaps these:

eval('ActualArrayID2=CarModelID'+ActualBrandID2+';');
eval('ActualArrayName2=CarModelName'+ActualBrandID2+';');


should be these?

eval('ActualArrayID2=CarModelID2'+ActualBrandID2+';');
eval('ActualArrayName2=CarModelName2'+ActualBrandID2+';');
Copy linkTweet thisAlerts:
@miobauthorNov 28.2008 — nope, that must be ok, bc there is big array of models yet if i change it as you said, models are blank in #2.:

CarModelID1=['0','1','2','3','4','5','19','2140','2646','6','7','10','11','12','2830','1651','1769','15','3243','16'];

CarModelID2=['0','29'];

CarModelName1=['all models','145 (40)','146 (71)','147 (129)','155 (14)','156 (259)','156 Sportwagon/Combi (96)','159 (18)','159 Sportwagon/Combi (17)','164 (16)','166 (74)','33 (23)','33 SW/Combi (3)','75 (3)','Brera (6)','Crosswagon (4)','GT (17)','GTV (22)','MiTo (9)','Spider (10)'];

CarModelName2=['all models','246 (1)'];
Copy linkTweet thisAlerts:
@MrNobodyNov 28.2008 — Then you'll need to step through it with a script debugger to find out where things are going wrong.
Copy linkTweet thisAlerts:
@miobauthorNov 28.2008 — that is what ?

tell me where to take it
Copy linkTweet thisAlerts:
@MrNobodyNov 28.2008 — Well, Firefox has an add-in called Firebug for script debugging. Internet Explorer has an add-in called the MS Script Debugger. I'm not familiar with other browsers, so I can't help you with them.
Copy linkTweet thisAlerts:
@miobauthorNov 30.2008 — great thanx, will try
×

Success!

Help @miob 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...