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

Store list box values in database using an array

P: 21
Hello friends ! ,

I am very new to java script.If anyone can help me then
I will be very very thankful to his/her.

I am using php and mysql in my project and I have one textarea and
one list boxes,now whenever user fill any value(email-Id) to textarea and press submit button then value going to listbox. These values are one or multiple , then they goes into list box , In list box these values are store in array .
I mean user insert any value(email-Id) to textarea seperated by comma or space. Then these are going to Listbox.... List Box values are store in database in form of array...
I am successfull to add & delete the value in listBox from textarea by using JavaScript ...But when I give array in list box for these values error comes. But when I dont use array for list box Error was not found ... And record goes into list box only....
But I can't fetch them with post or get method in php code to store in database.... I need your help, friends please help me to store list box values in databse By using array because these values are multiple ....

Ok !

Bye !
Nov 5 '07 #1
Share this Question
Share on Google+
9 Replies


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

I have changed the thread title to give it a better description. Please use a good thread title.

Post your code (using code tags please).
Nov 5 '07 #2

P: 21
Hello friends ! ,

I am very new to java script.If anyone can help me then
I will be very very thankful to his/her.

I am using php and mysql in my project and I have one textarea and
one list boxes,now whenever user fill any value(email-Id) to textarea and press submit button then value going to listbox. These values are one or multiple , then they goes into list box , In list box these values are store in array .
I mean user insert any value(email-Id) to textarea seperated by comma or space. Then these are going to Listbox.... List Box values are store in database in form of array...
I am successfull to add & delete the value in listBox from textarea by using JavaScript ...But when I give array in list box for these values error comes. But when I dont use array for list box Error was not found ... And record goes into list box only....
But I can't fetch them with post or get method in php code to store in database.... I need your help, friends please help me to store list box values in databse By using array because these values are multiple ....

Ok !

Bye !
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function removeOptions(selectbox)
  3. {
  4. var i;
  5. for(i=selectbox.options.length-1;i>=0;i--)
  6. {
  7. if(selectbox.options[i].selected)
  8. selectbox.remove(i);
  9. }
  10. }
  11. function addOption_list(selectbox){
  12. var selval
  13.  
  14. selval=document.drop_list.AddEmail.value;
  15.  
  16. addOption(document.drop_list.invitation_who_email, selval,selval);
  17. selval=document.drop_list.AddEmail.value="";
  18. }
  19. </script>
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <select id="invitation_who_email[]"  multiple name="invitation_who_email[]"  size="30" >
  4. </select>&nbsp;&nbsp;&nbsp;<br>
  5. <input type="text" name="AddEmail">
  6.  
  7. </body>
  8. </html>
  9.  
  10.  
  11.  
Nov 13 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Give the list box an id of "invitation_who_email" and access the element using document.getElementById("invitation_who_email") instead.
Nov 13 '07 #4

P: 21
Give the list box an id of "invitation_who_email" and access the element using document.getElementById("invitation_who_email") instead.
Hello Sir !

Can you explain me in brief.....
Excuseme Sir, I want to store List box element in Database, these elements are multiple so I use array to store them in database. Sir, I use Javascript to add some text(value) in List box from textarea. But Sir, in front end I see values appears in List box but they dont get added as option values of List box. Sir and when I use array at that time error occured.
Sir , tell me any or give me any trics to add values in List box when user enter in textarea or text box which is single or multiple. If values are multiple then they are seperated by comma or white space, then they are differentiate in List Box... After it when I click submit button then these List Box values(multiple or single) will going to Database in the Form of string.
Thanks for your reply, Sir . Please think on my problem , do action on it and give me your very important suggesion !

Ok !

Bye !
Nov 15 '07 #5

acoder
Expert Mod 15k+
P: 16,027
Put your form elements within form tags.

Your JavaScript code doesn't match with the HTML.

Your select element: [HTML]<select id="invitation_who_email[]" multiple name="invitation_who_email[]" size="30" >[/HTML]should be [HTML]<select id="invitation_who_email" multiple name="invitation_who_email[]" size="30" >[/HTML]and use document.getElementById("invitation_who_email") to refer to the form.
Nov 16 '07 #6

P: 21
Put your form elements within form tags.

Your JavaScript code doesn't match with the HTML.

Your select element: [HTML]<select id="invitation_who_email[]" multiple name="invitation_who_email[]" size="30" >[/HTML]should be [HTML]<select id="invitation_who_email" multiple name="invitation_who_email[]" size="30" >[/HTML]and use document.getElementById("invitation_who_email") to refer to the form.
Thak you Sir ! for your help ! I try this in my code !

ok !

Bye !
Nov 19 '07 #7

acoder
Expert Mod 15k+
P: 16,027
No problem. Let us know how you get on.

PS. document.getElementById("invitation_who_email") would refer to the select element, not the form.
Nov 19 '07 #8

P: 21
Thak you Sir ! for your help ! I try this in my code !

ok !

Bye !
THANKS sir , I overcome this problem with the help of your code.....

Thank you Sir !!!

Ok !

Bye !
Nov 30 '07 #9

acoder
Expert Mod 15k+
P: 16,027
THANKS sir , I overcome this problem with the help of your code.
Glad you got it working. Post again if you have any more questions.
Nov 30 '07 #10

Post your reply

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