I have the following scenario:
- Receive variables from the server.
- Select in a dropdown one of the values of a variable from the previous point.
- This dropdown has an "onchange" event that generates the elements of the next dropdown (cascading data load).
- The second dropdown must have another value of one of the variables (point 1) selected.
- Run a submit.
HTML
<select id="SelectID" name="SelectName" onchange="LlamarFuncion()">
<option value='Los Angeles'>Los Angeles</option>
<option value='San Bernardino'>San Bernardino</option>
<option value='Riverside'>Riverside</option>
<option value='Orange'>Orange</option>
</select>
<select id="SelectID2" name="SelectDetail">
</select>
javascript
<script>
function LlamarFuncion(){
//Esto demora
}
</script>
I tried to make a bind, a trigger and it didn't work. It happens to LlamarFuncion
take a while, so putting a setTimeout() would not be a good option either.
It is worth mentioning that the code is in a document ready
so it will run at a good pace.
Using jQuery this can be achieved by:
May the force be with you :D
Reference: http://api.jquery.com/jQuery.when/
I think it is not safe to execute functions from the labels, I hope and it works for you. This example works faster than loading directly from the tag