I tired of solving this problem but believe I'm missing something.
I'm not receiving values from request.getParameterValues of "mmsTitleAdded"
Here is the process I'm using:
This <tr> contains the MMSCategory list and onChange a javascript function is called which gets the the list of all the mmsTitles of that category:
Code for <tr> of MMSCategory & mmsTitles:
<tr class=blackbold>
<td class=TextFont>MMS Category</td>
<td class=TextFont>
<select name="MMSCategory" id="MMSCategory" style="width:148" onchange="javascript:fetchCannedMessaged(this.value);">
<%
%>
<option value="Select MMS Category">Select MMS Category</option>
<%
for(int i=0;i<mms_category.size();i++){
%>
<option value="<%=mms_id.get(i) %>"><%=mms_category.get(i) %></option>
<%
}
%>
</select>
</td>
</tr>
<tr class=blackbold>
<td class=TextFont>MMS Title</td>
<td class=TextFont>
<div id="render">
<select multiple="multiple" size=5 name="mmsTitle" id="mmsTitle" style="width:148" onchange="javascript:alert();">
<option value="Select MMS Title">Select MMS Title</option>
</select>
</div>
</td>
</tr>
This is JavaScript/AJAX function is called on onChange of a select list and gets the list of mmsTitles for the selected category.
function fetchCannedMessaged(val){
if(val == 'Select MMS Category'){
return;
}else{
document.getElementById('selected_MMSCategory').value = val;
alert("document.getElementById('selected_MMSCategory').value "+document.getElementById('selected_MMSCategory').value );
var xhttp;
if (window.XMLHttpRequest){
xhttp=new XMLHttpRequest();
}
else{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.onreadystatechange = function(){
if((xhttp.readyState == 4) && (xhttp.status == 200)){
var resp = xhttp.responseText;
alert(resp);
document.getElementById('render').innerHTML=resp;
}else{
}
}
var url = "Process_CannedMessages.jsp?mms_id="+val;
xhttp.open("POST",url,false);
xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xhttp.send(null);
}
}
Here is the relevant code of Process_CannedMessages.jsp which is called above in the AJAX function:
<%
Connection connlocal = null;
connlocal = DBUtils.getConnection("default");
System.out.println("->getPARAMETER: "+request.getParameter("mms_id"));
String mms_id = request.getParameter("mms_id");
String query = "select canned_id,title from proxy_canned_details where mms_categoryid='"+mms_id+"' ORDER BY canned_id DESC;";
Vector results = null;
String render ="";
render = "<table> <tr> <td> <select multiple='multiple' size=8 name='mmsTitle' id='mmsTitle' style='width:148' onchange=''>";
results = DBUtils.getVectorResult(connlocal,query);
String[]arr = new String[results.size()];
for(int i=0;i<results.size();i++){
arr = (String[])results.get(i);
render = render + "<option value='"+arr[0]+"'>"+arr[1]+"</option>";
}
render = render + "</select></td>";
render = render +"<td align ='top'><input type='button' value='<<' onClick='javascript:moveOptions(this.form.mmsTitleAdded,this.form.mmsTitle);'/>"
+"<input type='button' value='>>' onClick='javascript:moveOptions(this.form.mmsTitle, this.form.mmsTitleAdded);'/><NOBR></td>"
+"<td><select multiple='multiple' size=8 name='mmsTitleAdded' id='mmsTitleAdded' style='width:148'>"
+"</select></td> </tr> </table>";
String resp = ""+arr[0]+","+arr[1]+"";
System.out.println("resp:"+resp);
out.println(render);
%>
And Finally, (thank you for bearing this far)
I am submitting the form in which <tr> are defined (First Code above) whose action"Submit_package_details.jsp"
Here is the Code for Submit_package_details.jsp:
String pack_name = request.getParameter("selected_pack_name");
String mmsCategory = request.getParameter("selected_MMSCategory");
String scheduled_date = request.getParameter("scheduled_date");
String[]mmsTitleAdded = request.getParameterValues("mmsTitleAdded"); // PROBLEM AREA: NOT GETTING VALUE HERE
System.out.println(pack_name); // GETTING VALUE
System.out.println(mmsCategory); // GETTING VALUE
System.out.println(scheduled_date); // GETTING VALUE
for(int i=0;i<mmsTitleAdded.length;i++){
System.out.print(mmsTitleAdded[i]+" "); //NOT GETTING VALUE
}
NOT GETTING VALUES IN ABOVE CODE IN
String[]mmsTitleAdded = request.getParameterValues("mmsTitleAdded");
SINCERE THANK YOU FOR READING THIS FAR.