Megan Garrison
|
| Posted: 08/13/2001, 4:47 PM |
|
Hi - I hope one of you can help me - I have figured out how to get the
dependent listboxes to work (using the javascript in Alexey Alexapolsky's
example) but actually I needed 2 sets on one form (one for country/state and
a second set for species/breed). I got the second set working just fine
except for one glitch. the top category (species) has lists: All, Dogs,
Cats, and Other. Subcategories list the different breeds or each, or in the
case of "Other", then other species like birds, rabbits, ferrets, lizards,
etc. - Every thing works perfectly except when I select the "dog" category.
There are about 160 breed listed in the subcategory. Once I select the dog
category and then go to any of the other categories (All, Cats, Others) then
dog breeds show up in the list. somehow things are not getting set back to
square one in the "restore listbox settings" part of the code Any help or
ideas??? Thank you ~megan
|
|
|
 |
Alexey Alexapolsky
|
| Posted: 08/14/2001, 1:31 AM |
|
Currently I use the javascript below , it doesn't have that "restore"
section ,
also check the example file http://www.gotocode.com/UserImages/wake/php-listbox.zip http://www.gotocode.com/UserImages/wake/asp-listbox.zip
--
Alex
<script language="Javascript">
var cats = new Array();
var cats2 = new Array();
<!--Begincats-->
cats['{name}'] = '{id}';
<!--Endcats-->
<!--Begincats2-->
cats2['{name}'] = '{id}';
<!--Endcats2-->
function set_subcat(fform,llb1,llb2,ccats) {
lb1 = document.all[llb1];
lb2 = document.all[llb2];
key=lb1.options[lb1.selectedIndex].value.toString().split('#')[0];
for (i=document.forms[fform].elements[llb2].options.length; i >=0 ; i--) {
document.forms[fform].elements[llb2].options=null;
}
var i = 0 ;
for (iter in ccats) {
tmp = ccats[iter.toString()].split("#")[1];
// alert(key + " " + tmp);
if (tmp==key) {
// alert(iter.valueOf()+ " " + ccats[iter.toString()]);
document.forms[fform].elements[llb2].options = new
Option(iter.toString(),ccats[iter.toString()]);
i++;
}
}
}
function set_subcat3 () {
set_subcat("Form","countries","states",cats2);
}
function set_subcat2 () {
set_subcat("Form","continents","countries",cats);
set_subcat3();
}
document.Form.continents.options[0]=null;
document.Form.continents.onchange = set_subcat2;
document.Form.countries.onchange = set_subcat3;
set_subcat("Form","continents","countries",cats);
set_subcat("Form","countries","states",cats2);
</script>
|
|
|
 |
Megan Garrison
|
| Posted: 08/14/2001, 6:49 AM |
|
Thanks! ~Megan
"Alexey Alexapolsky" <alexa@codecharge.com> wrote in message
news:9lankt$90c$1@news.codecharge.com...
> Currently I use the javascript below , it doesn't have that "restore"
> section ,
> also check the example file
> http://www.gotocode.com/UserImages/wake/php-listbox.zip
> http://www.gotocode.com/UserImages/wake/asp-listbox.zip
>
> --
> Alex
>
>
> <script language="Javascript">
>
> var cats = new Array();
> var cats2 = new Array();
>
>
> <!--Begincats-->
> cats['{name}'] = '{id}';
> <!--Endcats-->
>
> <!--Begincats2-->
> cats2['{name}'] = '{id}';
> <!--Endcats2-->
>
>
> function set_subcat(fform,llb1,llb2,ccats) {
>
> lb1 = document.all[llb1];
> lb2 = document.all[llb2];
>
>
>
> key=lb1.options[lb1.selectedIndex].value.toString().split('#')[0];
>
>
>
> for (i=document.forms[fform].elements[llb2].options.length; i >=0 ; i--)
{
> document.forms[fform].elements[llb2].options=null;
> }
>
> var i = 0 ;
> for (iter in ccats) {
> tmp = ccats[iter.toString()].split("#")[1];
> // alert(key + " " + tmp);
> if (tmp==key) {
> // alert(iter.valueOf()+ " " + ccats[iter.toString()]);
> document.forms[fform].elements[llb2].options = new
> Option(iter.toString(),ccats[iter.toString()]);
> i++;
> }
> }
>
>
> }
>
>
>
> function set_subcat3 () {
> set_subcat("Form","countries","states",cats2);
> }
>
> function set_subcat2 () {
> set_subcat("Form","continents","countries",cats);
> set_subcat3();
> }
>
>
>
>
> document.Form.continents.options[0]=null;
> document.Form.continents.onchange = set_subcat2;
> document.Form.countries.onchange = set_subcat3;
>
> set_subcat("Form","continents","countries",cats);
> set_subcat("Form","countries","states",cats2);
>
> </script>
>
>
>
|
|
|
 |
|