Hi

I'm trying to create a select tag that has a child select tag
and this child tag choices are filtered by parent select tag.

The result is somethig like this.


<HTML>
<HEAD>
<TITLE>SELECT TAG</TITLE>
<SCRIPT LANGUAGE=JavaScript>
<!--
function funcSubmit() {
    if (document.formMain.pref.selectedIndex == 0 &&
document.formMain.city.selectedIndex == 0) {
        window.alert("Please choose prefecture and city");
        return false;
    } else if (document.formMain.pref.selectedIndex == 0) {
        window.alert("Please choose prefecture");
        return false;
    } else if (document.formMain.city.selectedIndex == 0) {
        window.alert("Please choose city");
        return false;
    } else {
        return true;
    }
}

function funcMain(b) {
    if (document.formMain.pref.selectedIndex == 0) {
        document.formMain.city.length = 1;
        document.formMain.city.selectedIndex = 0;
    } else {
        if (b) {
            document.formMain.city.length = 1;
            document.formMain.city.selectedIndex = 0;
        }
        var city = cities[document.formMain.pref.selectedIndex - 1];
        document.formMain.city.length = city.length + 1;
        for (var i = 0; i < city.length; i++) {
            document.formMain.city.options[i + 1].value = i;
            document.formMain.city.options[i + 1].text = city[i];
        }
    }
}

var prefs = new Array("PrefA", "PrefB", "PrefC", "PrefD");
var cities = new Array();
cities[0] = new Array("CityA1", "CityA2", "CityA3");
cities[1] = new Array("CityB1", "CityB2");
cities[2] = new Array("CityC1", "CityC2", "CityC3");
cities[3] = new Array("CityD1", "CityD2", "CityD3", "CityD4",
"CityD5");
// -->
</SCRIPT>
</HEAD>
<BODY onLoad="funcMain(false)">
<FORM NAME=formMain METHOD=POST ACTION=result.asp onSubmit="return
funcSubmit()">
<SELECT NAME="pref" onChange="funcMain(true)">
<OPTION VALUE="" SELECTED>Please Choose Prefecture
<OPTION VALUE="0">PrefA
<OPTION VALUE="1">PrefB
<OPTION VALUE="2">PrefC
<OPTION VALUE="3">PrefD
</SELECT>
<SELECT NAME="city">
<OPTION VALUE="" SELECTED>Please Choose City
<OPTION VALUE="">
<OPTION VALUE="">
<OPTION VALUE="">
<OPTION VALUE="">
<OPTION VALUE="">
<OPTION VALUE="">
<OPTION VALUE="">
</SELECT>
<INPUT TYPE=submit VALUE="Submit">
</FORM>
</BODY>
</HTML>


(I'm using Cakephp 1.1)
There are many posting regarding the one using ajax but not the one
without ajax

Can anybody paste a sample code to do this?

Regards.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to