简体   繁体   English

如何将所选值从下拉列表传递到下一页中的另一个下拉列表

[英]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.

相关问题 如何将下拉选择的值传递给另一个下拉菜单 - how to pass dropdown selected value to another dropdown 从最后一页传递值并在下拉列表PHP上自动选择 - Pass A Value From Last Page And Auto Selected On The Dropdown List PHP 使用ajax将所选下拉列表的值作为参数传递给另一个下拉列表中的函数 - Use ajax to pass the value of selected dropdown as an argument to a function in another dropdown 如何将一个模式中的下拉列表中的选定值传递给另一模式中的另一个下拉列表 - How to pass a selected value in a dropdown list in one modal to another dropdown list in another modal t 导航到另一个HTML页面后,如何在下拉列表中显示所选值? - How to display the selected value in dropdown after navigating to another html page? 从下一个下拉菜单中删除已选择的下拉值 - Remove a dropdown value that has been selected, from next dropdown menus 如何将选定页面中的选定值传递到下一页? - how to pass selected value from selected page to next page? 如何在Angularjs的contextscope中传递从下拉列表中选择的值? - How to pass the value selected from dropdown in contextscope in Angularjs? 无法通过ajax下拉列表传递所选值 - unable to pass selected value from ajax dropdown 如何在jQuery插件中传递下拉选择的值 - how to pass dropdown selected value in jquery plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM