By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Multiple selection using php w/ javascript

P: 2
I hope someone can help here;
I have two lists, with multiple selection, say one is employees and the other is called members, when names are moved from employees into the other list box they become members of a team.
the names of these members are to be inserted into the database, my problem is that the members are supposed to be stored in a javascript array and read by the php script to be saved in the database, when this is done only the first element of the array is saved.....Please help;
Thanks
May 20 '07 #1
Share this Question
Share on Google+
2 Replies


pbmods
Expert 5K+
P: 5,821
Heya, NourB. Welcome to TSDN!

the names of these members are to be inserted into the database, my problem is that the members are supposed to be stored in a javascript array and read by the php script to be saved in the database, when this is done only the first element of the array is saved.....Please help;
Thanks
Set the name of your select to "varname[]" (note the brackets):

Expand|Select|Wrap|Line Numbers
  1. <select name="mySet[]" multiple="multiple">
  2.     <option value="1">one</option>
  3.     etc.
  4. </select>
  5.  
For a working example, take a look at this page.
May 21 '07 #2

P: 2
Greetings;
Thanks for the help, but thats not quite what i'm looking for.
Inorder to move the names between the two lists i use a javascript function, after that i want to save the content of the second list in the db, but since its more than one item i would need to put them into an array....
here is a snippet of the code
Expand|Select|Wrap|Line Numbers
  1.  
  2.  <select size=8 name=employees  style='width: 250;' dir=rtl multiple='yes'>
  3.                     <option value=0></option>
  4.                     </select>
  5.                     </td>
  6.                     <td bgcolor=$color4 align=center>
  7.                     <input type=button value='>'  name=1 style='width: 70;' onclick='return nameXchange(document.meetings_frm.employees,document.meetings_frm.members[]);' ><br>
  8.                     <input type=button value='<'  name=1 style='width: 70;' onclick='return nameXchange(document.meetings_frm.members[],document.meetings_frm.employees);'><br>
  9.                     </td>
  10.                     <td bgcolor=$color4 align=right>
  11.                     <select size=8 name=members[]  style='width: 250;' dir=rtl multiple='yes'>
  12.                     </select>



Heya, NourB. Welcome to TSDN!



Set the name of your select to "varname[]" (note the brackets):

Expand|Select|Wrap|Line Numbers
  1. <select name="mySet[]" multiple="multiple">
  2.     <option value="1">one</option>
  3.     etc.
  4. </select>
  5.  
For a working example, take a look at this page.
May 22 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.