Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 3.67 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-13-2008, 10:01 PM   PM User | #1
anilreddy76
New Coder

 
Join Date: Jun 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
anilreddy76 is an unknown quantity at this point
Help-Inserting the data from Multi Select List box..

Hi,
Can Someone help me with this.
Only one value is inserted into the Db when I tried
to use the multiselect listbox and selected multiple values.

I need all the values I select from a listbox to be comma separated and
inserted in the coresponding Db column.

I'm using the java for inserting the data into database.

I've the following:

on Jsp I've like this

<html:select property="vpmoPmt" size="4" multiple="true" tabindex="3" >
<htmlptions collection="pmtlist" property="value" labelProperty="label"/>
</html:select>

On the Form I've the variable defined like this..

private String vpmoPmt[];

In the java code I'm doing this to set the value to insert the data into database table.

String[] vpmoPmt = requestForm.getVpmoPmt();

if (vpmoPmt != null && vpmoPmt.length > 0 ) {

StringBuffer pmt = new StringBuffer();

for ( int i = 0; i < vpmoPmt.length; i++ ) {

if ( pmt.length() > 0 ) {

pmt.append(", ");

}
pmt.append(vpmoPmt[i]);

pimVpmo.setPmt(vpmoPmt[i]);
}
}

Please advise me if I'm doing any thing wrong..

Thanks,
Anil
anilreddy76 is offline   Reply With Quote
Old 05-14-2008, 05:53 PM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
does it work? what errors do you get?
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:46 PM.


Advertisement
Log in to turn off these ads.