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

Auto Select Everything within a Select

Expand Messages
  • Shari Jung
    I have two drop down lists that I am moving data from one to another and vice versa. When the person clicks the submit button I need everything in one list to
    Message 1 of 3 , Dec 1, 1999
    • 0 Attachment
      I have two drop down lists that I am moving data from one to another and
      vice versa. When the person clicks the submit button I need everything in
      one list to be "selected" so I can enter them into a Database on the next
      page. Is there anyway to automatically select every option in a drop down
      list when the submit button is clicked?


      Thanks,

      Shari Jung
      sjung@... <mailto:sjung@...>
      812.482.8850
    • peter poranski
      Seems silly to me to do such a thing, or maybe I just didn t understand you, but here it is: function showSelected(f) { for(x = 0; x
      Message 2 of 3 , Dec 8, 1999
      • 0 Attachment
        Seems silly to me to do such a thing, or maybe I just
        didn't understand you, but here it is:


        <html>
        <head>
        <script>
        function showSelected(f) {
        for(x = 0; x < f.s1.length; x++) {
        if(f.s1.options[x].selected) {
        alert(f.s1.options[x].text);
        }
        }
        }

        function doIt(f) {
        showSelected(f);
        for(x=0; x<f.s1.length; x++) {
        f.s1.options[x].selected = true;
        }
        showSelected(f);
        return false;
        }
        </script>
        </head>
        <body>
        <form onSubmit="return doIt(theForm)" name="theForm">
        <select multiple name=s1>
        <option value=1> 1
        <option value=2> 2
        <option value=3> 3
        <option value=4> 4
        <option value=5> 5
        </select>
        <p>
        <input type=submit>
        </form>
        </body>
        </html>

        --- Shari Jung <sjung@...> wrote:

        <HR>
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
        <HTML>
        <HEAD>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
        charset=iso-8859-1">



        <META content='"MSHTML 4.72.3612.1700"'
        name=GENERATOR>
        </HEAD>
        <BODY bgColor=#ffffff>
        <DIV><SPAN class=48130616-01121999><FONT color=#000000
        face=Arial size=2>I have
        two drop down lists that I am moving data from one to
        another and vice
        versa.  When the person clicks the submit button
        I need everything in one
        list to be "selected" so I can enter them
        into a Database on the next
        page.  Is there anyway to automatically select
        every option in a drop down
        list when the submit button is
        clicked?</FONT></SPAN></DIV>
        <DIV> </DIV>
        <DIV> </DIV>
        <DIV><FONT color=#000000 face=Arial size=2></FONT>
        <DIV><SPAN class=380092116-30091999><FONT
        color=#000000 face=Arial
        size=2>Thanks,</FONT></SPAN></DIV>
        <DIV><SPAN class=380092116-30091999><FONT
        color=#000000 face=Arial
        size=2></FONT></SPAN> </DIV>
        <DIV><SPAN class=380092116-30091999><FONT
        color=#000000 face=Arial size=2>Shari
        Jung</FONT></SPAN></DIV>
        <DIV><SPAN class=380092116-30091999><FONT
        color=#000000 face=Arial size=2><A
        href="mailto:sjung@...">sjung@...</A></FONT></SPAN></DIV>
        <DIV><SPAN class=380092116-30091999><FONT
        color=#000000 face=Arial
        size=2>812.482.8850</FONT></SPAN></DIV></DIV>
        <DIV> </DIV>
        <DIV> </DIV>
        <DIV> </DIV></BODY></HTML>


        <HR>
        <html>
        >


        =====
        Peter Poranski
        __________________________________________________
        Do You Yahoo!?
        Thousands of Stores. Millions of Products. All in one place.
        Yahoo! Shopping: http://shopping.yahoo.com
      • Shari Jung
        There are actually two select boxes that I am moving items back and forth, so when submit is clicked I wanted what is in one box to be selected. I got it
        Message 3 of 3 , Dec 9, 1999
        • 0 Attachment
          There are actually two select boxes that I am moving items back and forth,
          so when submit is clicked I wanted what is in one box to be selected. I got
          it working the day after I sent the note, but thanks for responding.


          -----Original Message-----
          From: peter poranski [mailto:poranski@...]
          Sent: Wednesday, December 08, 1999 3:50 PM
          To: javascript@onelist.com
          Subject: Re: [javascript] Auto Select Everything within a Select


          From: peter poranski <poranski@...>

          Seems silly to me to do such a thing, or maybe I just
          didn't understand you, but here it is:


          <html>
          <head>
          <script>
          function showSelected(f) {
          for(x = 0; x < f.s1.length; x++) {
          if(f.s1.options[x].selected) {
          alert(f.s1.options[x].text);
          }
          }
          }

          function doIt(f) {
          showSelected(f);
          for(x=0; x<f.s1.length; x++) {
          f.s1.options[x].selected = true;
          }
          showSelected(f);
          return false;
          }
          </script>
          </head>
          <body>
          <form onSubmit="return doIt(theForm)" name="theForm">
          <select multiple name=s1>
          <option value=1> 1
          <option value=2> 2
          <option value=3> 3
          <option value=4> 4
          <option value=5> 5
          </select>
          <p>
          <input type=submit>
          </form>
          </body>
          </html>

          --- Shari Jung <sjung@...> wrote:

          <HR>
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
          <HTML>
          <HEAD>
          <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
          charset=iso-8859-1">



          <META content='"MSHTML 4.72.3612.1700"'
          name=GENERATOR>
          </HEAD>
          <BODY bgColor=#ffffff>
          <DIV><SPAN class=48130616-01121999><FONT color=#000000
          face=Arial size=2>I have
          two drop down lists that I am moving data from one to
          another and vice
          versa.  When the person clicks the submit button
          I need everything in one
          list to be "selected" so I can enter them
          into a Database on the next
          page.  Is there anyway to automatically select
          every option in a drop down
          list when the submit button is
          clicked?</FONT></SPAN></DIV>
          <DIV> </DIV>
          <DIV> </DIV>
          <DIV><FONT color=#000000 face=Arial size=2></FONT>
          <DIV><SPAN class=380092116-30091999><FONT
          color=#000000 face=Arial
          size=2>Thanks,</FONT></SPAN></DIV>
          <DIV><SPAN class=380092116-30091999><FONT
          color=#000000 face=Arial
          size=2></FONT></SPAN> </DIV>
          <DIV><SPAN class=380092116-30091999><FONT
          color=#000000 face=Arial size=2>Shari
          Jung</FONT></SPAN></DIV>
          <DIV><SPAN class=380092116-30091999><FONT
          color=#000000 face=Arial size=2><A
          href="mailto:sjung@...">sjung@...</A></FONT></SPAN></DIV>
          <DIV><SPAN class=380092116-30091999><FONT
          color=#000000 face=Arial
          size=2>812.482.8850</FONT></SPAN></DIV></DIV>
          <DIV> </DIV>
          <DIV> </DIV>
          <DIV> </DIV></BODY></HTML>


          <HR>
          <html>
          >


          =====
          Peter Poranski
          __________________________________________________
          Do You Yahoo!?
          Thousands of Stores. Millions of Products. All in one place.
          Yahoo! Shopping: http://shopping.yahoo.com
        Your message has been successfully submitted and would be delivered to recipients shortly.