I have a javascript autocomplete. The autocomplete function works. I have a php script where it pulls 'subtypes; from a 'type' in mysql and results correctly. but i can't seem to get javascript to pass on the 'type' value (dropdown) if it has changed after the page lode. How can i get this function to work correctly if I change the 'type' dropdown element in the form after the page load?
The Javascript:
<script>
$(document).ready(function(){
var e = document.getElementById("type");
var type = e.options[e.selectedIndex].value;
$("#subtype").autocomplete("autocomplete/subtype.php?type="+type, {
selectFirst: true
});
});
</script>
The HTML:
<select id="type" name="type">
<option value="option1" selected="selected">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
<option value="option4">option4</option>
</select> </p>
<p><input type="text" name="subtype" id="subtype" value="" placeholder="Sub-Type"></p>
Thank You for your help. I'm new to javascript.