Store list box values in database using an array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ajinkya
    New Member
    • Nov 2007
    • 21

    Store list box values in database using an array

    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 !
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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).

    Comment

    • Ajinkya
      New Member
      • Nov 2007
      • 21

      #3
      Originally posted by Ajinkya
      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 !
      Code:
      <script language="javascript">
      function removeOptions(selectbox)
      {
      var i;
      for(i=selectbox.options.length-1;i>=0;i--)
      {
      if(selectbox.options[i].selected)
      selectbox.remove(i);
      }
      }
      function addOption_list(selectbox){
      var selval
      
      selval=document.drop_list.AddEmail.value;
      
      addOption(document.drop_list.invitation_who_email, selval,selval);
      selval=document.drop_list.AddEmail.value="";
      }
      </script>
      [code=html]
      <html>
      <body>
      <select id="invitation_ who_email[]" multiple name="invitatio n_who_email[]" size="30" >
      </select>&nbsp;&n bsp;&nbsp;<br>
      <input type="text" name="AddEmail" >

      </body>
      </html>


      [/code]

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Give the list box an id of "invitation_who _email" and access the element using document.getEle mentById("invit ation_who_email ") instead.

        Comment

        • Ajinkya
          New Member
          • Nov 2007
          • 21

          #5
          Originally posted by acoder
          Give the list box an id of "invitation_who _email" and access the element using document.getEle mentById("invit ation_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 !

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            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="invitatio n_who_email[]" size="30" >[/HTML]should be [HTML]<select id="invitation_ who_email" multiple name="invitatio n_who_email[]" size="30" >[/HTML]and use document.getEle mentById("invit ation_who_email ") to refer to the form.

            Comment

            • Ajinkya
              New Member
              • Nov 2007
              • 21

              #7
              Originally posted by acoder
              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="invitatio n_who_email[]" size="30" >[/HTML]should be [HTML]<select id="invitation_ who_email" multiple name="invitatio n_who_email[]" size="30" >[/HTML]and use document.getEle mentById("invit ation_who_email ") to refer to the form.
              Thak you Sir ! for your help ! I try this in my code !

              ok !

              Bye !

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                No problem. Let us know how you get on.

                PS. document.getEle mentById("invit ation_who_email ") would refer to the select element, not the form.

                Comment

                • Ajinkya
                  New Member
                  • Nov 2007
                  • 21

                  #9
                  Originally posted by Ajinkya
                  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 !

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Originally posted by Ajinkya
                    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.

                    Comment

                    Working...