链接到extern php文件,其中链接还包含在链接网站上执行的JavaScript
问题描述:
我有一个page_x.php
这是没有什么特别的。我也有一个page_y.php
与包含下拉字段的表单。链接到extern php文件,其中链接还包含在链接网站上执行的JavaScript
我想要链接<a href="page_y.php">link</a>
从page_x.php
到page_y.php
其链接也会选择下拉菜单的第三个值。
我该怎么做?
更新:
我会检查。是的,我可以将代码添加到目标文件。
我也一直在考虑用php $_GET
这样做并设置默认值。
我很惊讶(我不是很有经验的JS),我无法添加一个JS /基于浏览器的代码,为用户选择ElementById
。
答
你可以这样做,只有当你可以在页面上插入一个脚本的下拉
<a href="pagey.html?2">Load and select the 3rd value</a>
pagey:
<script type="text/javascript">
window.onload=function() {
var passed = location.search;
if (passed) {
var sel = parseInt(location.search.substring(1));
document.getElementById('selectID').selectedIndex=sel;
}
}
</script>
<select id="selectID">...