Okay my problem is i have a form which contains a select tag which needs to be dynamically populated from a Database, the values populated are determined by the postcode/zipcode a user enters WITHOUT submitting the form.
for example a postcode of 1234, the drop down list will contain values x1, x2, x3 but if a postcode of 4321, the drop down list will contain values y1, y2, y3
I have done some testing and my sql statement is perfectly fine, as i can populate the tag on submitting the form, yet i dont know how to implement on how to do this without submitting the page.
I understand the difference between JS and PHP, but could a onblur() JS function be used to dynamically change the drop down device, with calling a PHP function or having embedded PHP code somehow inside...
im stumped on how to do this with just Javascript or PHP..(since it's an assignment) and yes i have looked on how to do this.
you need onchange()
and an ajax
method to re-load the select
https://developer.mozilla.org/en-US/docs/Web/API/element.onchange
so once you select an option the select tree is re-loaded via ajax
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.