Loading ...
Sorry, an error occurred while loading the content.
 

How to select multiple option values????????????

Expand Messages
  • bhavin_s18
    Message 1 of 2 , Mar 1, 2006
      <head>
      <script type="text/javascript">
      <!--
      function setOpt(){
      alert (form1.sections.options.length);
      sections.options[i].selected = true;
      }
      submit();
      }
      -->
      </script>
      </head>
      <body>
      <form name="form1" action="test.htm" method="POST">
      <P>Select one or more sections to search:
      <SELECT NAME="sections" MULTIPLE>
      <OPTION value="1">Web Authoring Reference</OPTION>
      <OPTION value="2">FAQ Archives</OPTION>
      <OPTION value="3">Design Elements</OPTION>
      <OPTION value=" 4">Tools</OPTION>
      <OPTION value=" 5">Feature Article</OPTION>

      </SELECT>
      </P>
      <input type="submit" onClick="setOpt()">
      </form>
      </body

      Now when i select multiple values and submit, i get only one value. I
      Want to store multiple values in the array. how do i do this?
      Regards
      Bhavin
    • MA Razzaque Rupom
      Hi, Rename the select name to sections[] instead of sections so that it can be treated as an array. ...
      Message 2 of 2 , Mar 1, 2006
        Hi,

        Rename the select name to "sections[]" instead of "sections" so that
        it can be treated as an array.

        So now the select code looks like:

        ---------------------------------------
        <SELECT NAME="sections[]" MULTIPLE>
        <OPTION value="1">Web Authoring Reference</OPTION>
        <OPTION value="2">FAQ Archives</OPTION>
        <OPTION value="3">Design Elements</OPTION>
        <OPTION value=" 4">Tools</OPTION>
        <OPTION value=" 5">Feature Article</OPTION>

        </SELECT>
        -----------------------------------------------

        In the server side when you will grab this request data, it will
        return an array of the selected elements.


        Regards,

        Rupom

        --- In phpresource@yahoogroups.com, "bhavin_s18" <bhavin_s18@...> wrote:
        >
        > <head>
        > <script type="text/javascript">
        > <!--
        > function setOpt(){
        > alert (form1.sections.options.length);
        > sections.options[i].selected = true;
        > }
        > submit();
        > }
        > -->
        > </script>
        > </head>
        > <body>
        > <form name="form1" action="test.htm" method="POST">
        > <P>Select one or more sections to search:
        > <SELECT NAME="sections" MULTIPLE>
        > <OPTION value="1">Web Authoring Reference</OPTION>
        > <OPTION value="2">FAQ Archives</OPTION>
        > <OPTION value="3">Design Elements</OPTION>
        > <OPTION value=" 4">Tools</OPTION>
        > <OPTION value=" 5">Feature Article</OPTION>
        >
        > </SELECT>
        > </P>
        > <input type="submit" onClick="setOpt()">
        > </form>
        > </body
        >
        > Now when i select multiple values and submit, i get only one value. I
        > Want to store multiple values in the array. how do i do this?
        > Regards
        > Bhavin
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.