I have a jsp page named "tvshow.jsp", wherein I am populating the characters dropdown as and when the TV Show dropdown value changes , by calling the javascript in the “onchange()” of the select box. have added a html link, and I want to call the same function from my action class and I need to populate the character dropdown by clicking the html link. I am stuck up with this issue.Character dropdown is not populated with the data from tha action class. Need some help on this please!
<%@ page import="java.util.*"%> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> <script language="javascript"> function retrieveURL(url) { if (window.XMLHttpRequest) { // Non-IE browsers req = new XMLHttpRequest(); req.onreadystatechange = processStateChange; try { req.open("GET", url, true); } catch (e) { alert(e); } req.send(null); } else if (window.ActiveXObject) { // IE req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = processStateChange; req.open("GET", url, true); req.send(); } } } function processStateChange() { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response document.getElementById("characters").innerHTML = req.responseText; } else { alert("Problem: " + req.statusText); } } } </script> <form action="ShowCharacters"> /jsp/tvshow.jsp Click here TV Show: <select name="TVShowSelect" onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);"> <option value="Lissie Maguire"> Lissie Maguire </option> <option value="That’s so Raven"> That’s so Raven </option> <option value="Dhoom machale"> Dhoom machale </option> </select> <br> Characters: </form> ShowCharacters.jsp <[EMAIL PROTECTED] import="java.util.ArrayList"%> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> <select name="TVShowSelect"> <% ArrayList ch = (ArrayList)request.getSession().getAttribute("characters"); String[] s = new String[ch.size()]; ch.toArray(s); for (int i = 0; i < s.length; i++) { String name = s[i]; %> <option><%=name%></option> <% } %> </select> Thanks -- View this message in context: http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13138152 Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]