开发者

link to extern php-file where the link also contains javascript which is executed on the linked website

开发者 https://www.devze.com 2022-12-28 15:02 出处:网络
I have a page_x.php which is nothing special. I also have a page_y.php with a form containing a dropdown field.

I have a page_x.php which is nothing special. I also have a page_y.php with a form containing a dropdown field.

I want to place a link <a href="page_y.php">link</a> from page_x.php to page_y.php whose link will also select the third value of the dropdown.

How do I do this?

Update:

With regard to mplungjan's answer:

I will check that. Yes I can add code to the target-file.

I've also have been thinking about doing that wit开发者_如何转开发h php $_GET and setting the default value.

I am surprised (am not very experienced in JS) that I could not add a JS/browserbased code which selects the ElementById for the user.


You can do that only if you can insert a script on the page with the dropdown

<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">...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号