I created a Cascading of Dropdown list for Country state city in my application using Ajax request and Select Box. My application gathers information about users ie personal info etc. In my application there is an option to Edit the entered fields.. upon clicking the edit button the personal information page is populated with previously entered data. Now i need help to show the selected value that is which country, state and city is selected by the user in my select box dropdown. Please help!!
我使用Ajax请求和Select Box在我的应用程序中为Country州城创建了一个Cascading of Dropdown列表。我的应用程序收集有关用户的信息,即个人信息等。在我的应用程序中,有一个选项可以编辑输入的字段..单击编辑按钮后,个人信息页面将填充先前输入的数据。现在我需要帮助来显示所选值,即用户在我的选择框下拉列表中选择了哪个国家/地区,州和城市。请帮忙!!
1 个解决方案
#1
1
you should store the old values for each select box and resume it after loading values from ajax like
你应该存储每个选择框的旧值,并在从ajax加载值之后恢复它
var old_val = $('#state').val();
$('#state').html('<here option string from ajax>');
$('#state').val(old_val);
now when you show the dropdown for edit you can get the selected values from database and generate one option tag for all three dropdowns
现在,当您显示编辑下拉列表时,您可以从数据库中获取所选值,并为所有三个下拉列表生成一个选项标记
once loaded you can trigger chain of ajax for the same and values will not lost
一旦加载,你就可以触发ajax链,并且值不会丢失
#1
1
you should store the old values for each select box and resume it after loading values from ajax like
你应该存储每个选择框的旧值,并在从ajax加载值之后恢复它
var old_val = $('#state').val();
$('#state').html('<here option string from ajax>');
$('#state').val(old_val);
now when you show the dropdown for edit you can get the selected values from database and generate one option tag for all three dropdowns
现在,当您显示编辑下拉列表时,您可以从数据库中获取所选值,并为所有三个下拉列表生成一个选项标记
once loaded you can trigger chain of ajax for the same and values will not lost
一旦加载,你就可以触发ajax链,并且值不会丢失