link to extern php-file where the link also contains javascript which is executed on the linked website
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">...
精彩评论