The pull-down linkage between the province and the city. the provincial and municipal content is extracted from the database. now the province is selected. after the corresponding city is released, the province returns to its original value, the selected value cannot be saved because the screen is refreshed. Is there any way to save or avoid refreshing images? Below are some Codes & lt; p & nbsp; & gt; & lt; label & nbsp; forstate & gt; Province & drop-down Association problems
The interaction between province and city means that the content of the province and city is obtained from the database,
Now the province is selected. after the city comes out, the province returns to the initial value. The selected value cannot be saved because the screen is refreshed.
Is there any way to save or avoid refreshing images?
Below is some code
Save
City
// Initial stage, bind to Province
Public function action ()
{
$ RetArr = array ();
// Provincial acquisition
$ RetArr = $ this-> qaModel-> getProvince ();
If (count ($ retArr)> 0)
{
Foreach ($ retArr as $ key => $ I)
{
$ ProvinceList [$ I ["PROVINCE_KEY"] = $ I ["PROVINCE_NAME"];
}
}
// Obtain zookeeper configurations.
$ This-> _ smarty-> assign ("provinceList", $ provinceList );
// When the picture is merged, it indicates that the screenshot is displayed in this step. submit.html
$ This-> _ smarty-> render ($ this-> _ language. "/submit ");
}
// Linkage, binding city
Public function cityAction ()
{
$ Province_key = $ this-> _ context-> query ("province_key ","");
$ This-> log-> info ($ province_key );
$ RetArr = array ();
// Provincial acquisition
$ RetArr = $ this-> qaModel-> getCity ($ province_key );
If (count ($ retArr)> 0)
{
Foreach ($ retArr as $ key => $ I)
{
$ CityLis [$ I ["CITY_KEY"] = $ I ["CITY_NAME"];
}
}
// Obtain zookeeper configurations.
$ This-> _ smarty-> assign ("cityList", $ cityLis );
// When asked, the merge operator picture indicates that the merge operator will return to the initial stage, saving the trouble of re-binding.
$ This-> action ();
}
------ Solution --------------------
What is your messy Japanese website? Japanese? Toamachi, an urban district, yudaofu county, Japan.
We recommend that you use ajax. In this way, you do not need to refresh each time.
Duodao mansion{Html_options options = $ res. m_states selected = $ res. mst_state_id------ Solution --------------------Default :""}
Town-Cho village{Html_options options = $ res. m_city selected = $ res. mst_city_id------ Solution --------------------Default :""}
Function Linkage (obj, id ){
Var param = {};
Param. mst_state_id = obj;
$. Ajax ({
Type: "POST"
, Url: "php"
, Data: $. param (param)
, DateType: "xml"
, Success: function (xml ){
Var selects = $ ("select [id =" + id + "]");
$ (Selects) [0]. length = 0;
$ (Selects) [0]. options [0] = new Option ("Town Village", "0 ");
$ ("Category", xml). each (function (){
Var id = $ ("id", this). text ();
Var name = $ ("name", this). text ();
$ (Selects) [0]. options. add (new Option (name, id ));
});
}
});
}
Url: "php". here is the php note path that accepts the id of the prefectures and counties.
The php final output
$ Str = "";