I have a drop down and have a JavaScript function tied to the onchange event of the drop down.I need to call a action class with the drop down selected value and fetch data from database.I need pointers to call the action class from JavaScript and also pass the selected value of drop down to fire a DB select query and update a table present in a div withou refreshing the whole page.
My drop down
<s:select name="newQuestion.CertificationId" list="certificationList"
listKey="certificationId" listValue="certificationName" headerKey=""
headerValue="Select Certification" label="Certification Name"
onchange="getQuestionsList(this.value)" />
Javascript function
function getQuestionsList(val) {
alert("Here" + val);
}
Basically for each of the drop down selected values I need a ajax call to DB to populate a div which is hidden currently.
What exactly is it you need assistance with? From what I understand, you have it all figured out (minus the ajax call to the Struts action).
All you need to make it work is:
Some helpful Google hits: Struts and Ajax Working Together , Changing content on the fly using Javascript .
You have the right direction, now go and make the final touches.
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.