【发布时间】:2014-06-23 13:40:45
【问题描述】:
假设我有两个包含相同选择框的 html 页面:
<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
<option value="/site1.php">Site1</option>
<option value="/site2.php">Site2</option>
</select>
我正在寻找一种将 selectedIndex 的值传递到下一页的方法,因此我也可以在第二页选择框中使用它。有什么建议吗?
提前致谢
【问题讨论】:
-
可以通过POST、GET、COOKIE、SESSION、localStorage传递
-
问题是当我通过 php 传递它时,我无法通过 javascript 设置 selectedindex,因为我无法访问 php 变量。
标签: javascript html select onchange