• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cant get complete values from javascript to JSP code  RSS feed

 
John Eva
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo, i got a problem in sending values from javascript to JSP code so that i can call java statement and insert the values into database(Oracle)

My code:

///////////AdminDetail.jsp/////////


Java code to call java function and insert data

{But the problem is every time i submit values,the values that the java function get is not complete in example i submit 3 values from one select box , i only get one value sometimes.}can i know any solutions for this?



[BSouther: Added UBB CODE tags]
[ October 31, 2007: Message edited by: Ben Souther ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Eva:

{But the problem is every time i submit values,the values that the java function get is not complete in example i submit 3 values from one select box , i only get one value sometimes.}can i know any solutions for this?


If you're trying to retrieve multiple parameters with the same name (ie: a multiple entry select field), you need to use request.getParameterValues; which returns a String[].
 
John Eva
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya,i assign the array into a String []
but the values i get is only one array like i select three values,
it should be :
array[1]= "Apple",
array[2]= "Pineapple"
array[3]= "Pineapple"
but the result is
array [0] = "Apple,Pineapple,Cherry"
//////////////////////////////////////
javascript function
function save (){
var Slen = form.sel2.length ;
var len = Slen - 1;
var cnt = 0;
//alert(len)
var a = new Array();
var ii =0;

if(!confirm("Are you want to save all the settings that you had done?")) return;



if(form.Grade.value == "" ){
alert("Please Select Grade!")
form.Grade.focus();
return
}else if(form.sel2.length == 0){
alert("Please Select Department!")
form.sel1.focus();
return
}

form.dep.value = form.Udp.value;
form.id.value = form.Uid.value;
form.SaveGrd.value = form.Grade.value ;

form.passdep.value = form.dep.value;
form.passid.value = form.id.value;
form.SaveYn.value = "Y";


if(form.sel2.length > 0){

for(var tt = 0;tt<= len;tt++){

cnt = cnt +1;

}
form.count.value = cnt ;
for(var f= 0 ;f<= len;f++){

//a[ii] = new Array ();
a[ii] = form.sel2[f].value ;
form.SaveID.value = form.Uid.value ;

//alert(a[ii])
//alert(form.SaveDep.value)
//alert("Dept code " +form.SaveDep.value)
//alert("ID "+form.SaveID.value)
//alert("User Grd " +form.SaveGrd.value)
form.SaveDep.value = a;

ii = ii +1;

form.action = "AdminDetail.jsp";
form.submit();
}}}

/////////////JSP Statement////////////////
String []Getdpt = request.getParameterValues("SaveDep");
/*Getdpt's values only consists of one string values*/

{I am trying to get not only one string values in one array
Please Advise,Thank You}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!