views:

41

answers:

2

hi

i have a page x which is nothing special. i also have a page y with a form -> dropdown-field.

Now i want to place a link link from page x to page y whose link will also select the third value of the dropdown.

The sample is descriped easier than it is in reality just to get to the point.

How is that doable?

Regards

A: 

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">...
mplungjan
A: 

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

i also have been thinking about doing that with 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.

Thx for your help

Malteser