This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Cant get complete values from javascript to JSP code

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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}
 
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic