Pull-down Association

Source: Internet
Author: User
The pull-down linkage between the province and the city. the provincial and municipal content 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


// Initially, bind the province public function action () {$ retArr = array (); // the province gets $ retArr = $ this-> qaModel-> getProvince (); if (count ($ retArr)> 0) {foreach ($ retArr as $ key => $ I) {$ provinceList [$ I ["PROVINCE_KEY"] = $ I ["PROVINCE_NAME"] ;}/// get the original response? Too many? Set $ this-> _ smarty-> assign ("provinceList", $ provinceList); // Configure? When combined, the screenshot watermark indicates that the screenshot watermark displays the image submit.html $ this-> _ smarty-> render ($ this-> _ language. "/submit");} // linkage, binding public function cityAction () {$ province_key = $ this-> _ context-> query ("province_key ",""); $ this-> log-> info ($ province_key); $ retArr = array (); // Obtain $ retArr = $ this-> qaModel-> getCity ($ province_key ); if (count ($ retArr)> 0) {foreach ($ retArr as $ key => $ I) {$ cityLis [$ I ["CITY_KEY"] = $ I ["CITY_NAME"] ;}/// obtain the desired parameter? Too many? Set $ this-> _ smarty-> assign ("cityList", $ cityLis); // parameters? When combined, the image watermark indicates that zookeeper is returned to the initial stage. in this way, $ this-> action ();} is rebound ();}


Reply to discussion (solution)

Japanese? If you do not need to refresh, you must pass the ajax value.

See Ajax:

 Error:".mysql_error());if(mysql_affected_rows() > 0){$arrMenu=array();while($rows = mysql_fetch_array(MYSQL_ASSOC)){array_push($arrMenu,$rows);}}mysql_close();if(!empty($arrMenu)){echo "";foreach($arrMenu as $item2){echo "{$item2['name']}";}echo "";}}?>

《script》$("select").live("change",function(){$.ajax({  type: "GET",  url: "action.php",  data: "id="+$(this).val(),  cache: false,  success: function(text){    $("#show").append(text);  }});});

This is about ajax.

Too many other users.


Upload the id of the selected province and city.

Too many other users.


Upload the id of the selected province and city.



Make sure it is done, or refresh it.

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 | default :""}
Town-Cho village {Html_options options = $ res. m_city selected = $ res. mst_city_id | 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 = "";
Foreach ($ m_state2 as $ key => $ val ){
$ Str. =" ". $ Key ." ". $ Val ." ";
}
Header ("Content-Type: text/xml; charset = utf-8 ");
Echo' '. Mb_convert_encoding ($ str, "UTF-8 ").'';
Exit;

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 ...... Grace is worth a try ~~ See Ajax:PHP code # Action. phpIf (isset ($ _ GET ['id']) {$ SQL = "select * from table where id =". $ _ GET ['id'];$ Res = mysql_query ($ SQL );If (! $ Res) die ("SQL: {$ SQL}Error: ". mysql_error ()...... I don't understand ajax. $ ("Select"). live ("change", function (){$. Ajax ({Type: "GET ",Url: "action. php ",Data: "id =" + $ (this). val (),Cache: false,Success: function (text ){$ ("# Show"). append (text );}});}); Where is this code written? $ _ GET ['id'] is the province id? What is written in the redirec (this. value) method? 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 ......



It is a Chinese website and has three language versions.

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 ...... "Param. mst_state_id = obj;" is "mst_state_id" an attribute or something? This
Mst_state_id is the property of your select statement. You just need to name it as long as it can be unified. You can change it to your state.

Reference the reply on the second floor:

See Ajax:
PHP code
# Action. php
If (isset ($ _ GET ['id']) {
$ SQL = "select * from table where id =". $ _ GET ['id'];
$ Res = mysql_query ($ SQL );
If (! $ Res) die ("SQL: {$ SQL}
Error: ". mysq ......



 Script // Ajax-jquery, must load the jQuery library: jquery_1.4.2.jsdocument.write ("

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.