Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •