P
phl
I have static html <select> dropdowns in my page. I need to be able to
select an item from the dropdown dynamically. I won't know which item
it will be till run time. I will parse the url, try match item and
select it from choosen dropdowns. such as the example below:
url= http://localhost/mysite.asp?country=Alaska
<script>
selectitem(item, dropdownid) {...}
</script>
<select id="countryddl" name="country">
<option value="Alaska">Alaska</option>
<option value=...>...</option>
</select>
I can write a js function to do this. The problem is that I don't know
where to call this function. It seems the only place I can do this is
from <body>, as this has the onload event associated with it, but I
dont' have access to the <body> tag, as the page i am working on is
pieced together at run time.<select> don't have a suitable event
associated with it to do this. I tried calling it from <script> but it
can't find the dropdowns, beucase they have not be rendered yet at
that stage.
So for this problem, I need to be able to dynamically generate
parameters for my javascript function based on what I find in url. I
need to call it somewhere so the javascript function will be called. I
can't see how I can do this. Have I missed something?
If I generate all my dropdowns dynamically instead I will be able to
solve this problem. Before I do so I would like to know if I can solve
this problem with the above method.
cheers
-P
select an item from the dropdown dynamically. I won't know which item
it will be till run time. I will parse the url, try match item and
select it from choosen dropdowns. such as the example below:
url= http://localhost/mysite.asp?country=Alaska
<script>
selectitem(item, dropdownid) {...}
</script>
<select id="countryddl" name="country">
<option value="Alaska">Alaska</option>
<option value=...>...</option>
</select>
I can write a js function to do this. The problem is that I don't know
where to call this function. It seems the only place I can do this is
from <body>, as this has the onload event associated with it, but I
dont' have access to the <body> tag, as the page i am working on is
pieced together at run time.<select> don't have a suitable event
associated with it to do this. I tried calling it from <script> but it
can't find the dropdowns, beucase they have not be rendered yet at
that stage.
So for this problem, I need to be able to dynamically generate
parameters for my javascript function based on what I find in url. I
need to call it somewhere so the javascript function will be called. I
can't see how I can do this. Have I missed something?
If I generate all my dropdowns dynamically instead I will be able to
solve this problem. Before I do so I would like to know if I can solve
this problem with the above method.
cheers
-P