[英]how to pass selected value from dropdown to another dropdown in next page
I have a form when user select value from dropdown it can direct them to another page.but in the next page I want the selected value to be pass to another dropdown.我有一个表单,当用户 select 值从下拉列表中时,它可以将它们定向到另一个页面。但是在下一页中,我希望将所选值传递到另一个下拉列表。
for instance: user select country;例如:用户 select 国家; then go straight to the next page where there is a dropdown already selected the country value.然后 go 直接到下一页,其中有一个下拉菜单已经选择了国家值。 then only they can do the next process...然后只有他们可以做下一个过程......
note:(list item in the dropdown is same as the 1st)注意:(下拉列表中的列表项与第一个相同)
hope anyone can help me.希望任何人都可以帮助我。
thanks.谢谢。
Simply you can store the first-page dropdown values in Session or Cookies.只需将首页下拉值存储在 Session 或 Cookies 中。 If you have less important things like country, cities, and address locations then you can simply use the Cookies to store the data.如果您有不太重要的东西,例如国家、城市和地址位置,那么您可以简单地使用 Cookies 来存储数据。
You can use url parameter to pass the selected value from one page to another.您可以使用 url 参数将所选值从一页传递到另一页。
http://www.test.com/next_page.php?selected_value=12
Like above example you can pass the selected drop down value to another page in php.与上面的示例一样,您可以将选定的下拉值传递到 php 中的另一个页面。
You can use您可以使用
$_GET['selected_value']
in next page to get selected value.在下一页中以获取选定的值。
You have to get select value by doing onChange
event via jquery.您必须通过 jquery 执行onChange
事件来获取 select 值。
After jquery, you need to pass that value to particular change event.在 jquery 之后,您需要将该值传递给特定的更改事件。
Lets say you have this select box假设你有这个 select 盒子
<select id="select1">
<option value"">Select</option>
<option value"1">A</option>
<option value"1">b</option>
<option value"1">C</option>
</select>
While if any value changes you need to navigate to that page taking that option value.如果任何值发生变化,您需要导航到采用该选项值的页面。
So this is how you can do it via jquery.所以这就是你可以通过 jquery 做到这一点的方法。
$("#select1").change(function(){
//alert();
var changedval = $(this).val();
var url = "pagename/countryname="+changedval;
window.location.href= url;
/* $.ajax({
url: url,
type: 'GET',
data: {'image_name': image_name, 'id' : id},
success: function (data) {
$("#profile_picture_display_outer").hide();
},
error: function (data) {
}
}); */
});
You can even get values via ajax as well or you can directly redirect to that particular url via appending current selected value.您甚至可以通过 ajax 获取值,或者您可以通过附加当前选择的值直接重定向到特定的 url。
Additional if you are using Codeigniter 3 then this is how you can mention routes in routes.php另外,如果您使用的是 Codeigniter 3,那么这就是您可以在 routes.php 中提及路由的方式
$route['pagename/(:any)'] = 'Controller/methodname/$1';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.