on submit, select all

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ike

    on submit, select all

    I have a form I am Posting. On that form, I have a selection list,
    selectedList... .wherein I want to make all the items that are within that
    lest be selected, automatically, when the submit button is hit.

    Is there a way to do this? Thanks, Ike


  • kaeli

    #2
    Re: on submit, select all

    In article <kkhIb.15372$IM 3.13677@newsrea d3.news.atl.ear thlink.net>,
    rxv@hotmail.com enlightened us with...[color=blue]
    > I have a form I am Posting. On that form, I have a selection list,
    > selectedList... .wherein I want to make all the items that are within that
    > lest be selected, automatically, when the submit button is hit.
    >
    > Is there a way to do this? Thanks, Ike[/color]

    Um, why?
    Rather defeats the purpose.

    Can you do it? Yeah. Should you? Probably not. You probably want another
    type of control.

    --
    --
    ~kaeli~
    Condoms should be used on every conceivable occasion.



    Comment

    • Lee

      #3
      Re: on submit, select all

      Ike said:[color=blue]
      >
      >I have a form I am Posting. On that form, I have a selection list,
      >selectedList.. ..wherein I want to make all the items that are within that
      >lest be selected, automatically, when the submit button is hit.
      >
      >Is there a way to do this? Thanks, Ike[/color]

      Yes, provided that you also allow the user to select as many
      items as they like, but it's a bad idea. It means that your
      server-side code won't receive data that it needs if the user
      has disabled JavaScript.

      List all of the available options in a hidden form field or
      hard-code them into the server-side script, or write them down
      and tape the list to your monitor, depending on how you're
      processing the form data.

      Comment

      • Ike

        #4
        Re: on submit, select all

        Its a drag and drop control. Elements are dragged into or out of it. I want
        to select it all before submit is hit.

        Thanks for the advice on condoms too, I never thought of that. Ike

        "kaeli" <tiny_one@NOSPA M.comcast.net> wrote in message
        news:MPG.1a5b67 efd6d845e989a54 @nntp.lucent.co m...[color=blue]
        > In article <kkhIb.15372$IM 3.13677@newsrea d3.news.atl.ear thlink.net>,
        > rxv@hotmail.com enlightened us with...[color=green]
        > > I have a form I am Posting. On that form, I have a selection list,
        > > selectedList... .wherein I want to make all the items that are within[/color][/color]
        that[color=blue][color=green]
        > > lest be selected, automatically, when the submit button is hit.
        > >
        > > Is there a way to do this? Thanks, Ike[/color]
        >
        > Um, why?
        > Rather defeats the purpose.
        >
        > Can you do it? Yeah. Should you? Probably not. You probably want another
        > type of control.
        >
        > --
        > --
        > ~kaeli~
        > Condoms should be used on every conceivable occasion.
        > http://www.ipwebdesign.net/wildAtHeart
        > http://www.ipwebdesign.net/kaelisSpace
        >[/color]


        Comment

        • McKirahan

          #5
          Re: on submit, select all

          "Ike" <rxv@hotmail.co m> wrote in message
          news:kkhIb.1537 2$IM3.13677@new sread3.news.atl .earthlink.net. ..[color=blue]
          > I have a form I am Posting. On that form, I have a selection list,
          > selectedList... .wherein I want to make all the items that are within that
          > lest be selected, automatically, when the submit button is hit.
          >
          > Is there a way to do this? Thanks, Ike[/color]


          Perhaps this?


          <html>
          <head>
          <title>selected .htm</title>
          <script language="javas cript" type="text/javascript">
          <!--
          function selectList() {
          var form = document.forms[0];
          for (var i=0; i<form.selected List.length; i++) {
          form.selectedLi st.options[i].selected = true;
          }
          return false;
          }
          // -->
          </script>
          </head>
          <body>
          <form method="post" onsubmit="retur n selectList()">
          <b>Numbers:</b>
          <br>
          <select name="selectedL ist" multiple size="4">
          <option value="1">One
          <option value="2">Two
          <option value="3">Three
          <option value="4">Four
          </select>
          <br><input type="submit" value="Submit">
          <br><input type="reset" value="Clear">
          </form>
          </body>
          </html>


          1) Change "return false;" to "return true;" after testing.
          2) Change or remove: size="4"


          Comment

          • kaeli

            #6
            Re: on submit, select all

            In article <H1iIb.15401$IM 3.6041@newsread 3.news.atl.eart hlink.net>,
            rxv@hotmail.com enlightened us with...[color=blue]
            > Its a drag and drop control. Elements are dragged into or out of it. I want
            > to select it all before submit is hit.
            >[/color]

            Well, assuming the user has javascript enabled, which I assume they must
            for the drag and drop to work, you can just make it a mutli-select and
            then iterate through the options and set selected to true for each one.
            You cannot do this before submit is hit - you do it in the onClick of
            the submit button, before the event is propagated to the onSubmit
            handler.

            See McKirahan's reply.

            --
            --
            ~kaeli~
            The more ridiculous a belief system, the higher probability
            of its success.



            Comment

            • Ang Talunin

              #7
              Re: on submit, select all


              "Ike" <rxv@hotmail.co m> schreef in bericht
              news:kkhIb.1537 2$IM3.13677@new sread3.news.atl .earthlink.net. ..[color=blue]
              > I have a form I am Posting. On that form, I have a selection list,
              > selectedList... .wherein I want to make all the items that are within that
              > lest be selected, automatically, when the submit button is hit.
              >
              > Is there a way to do this? Thanks, Ike[/color]

              ok..
              put this in the head:

              </script>
              function selectAll(row)
              {
              for (i = 0; i<row.options.l ength;i++)
              {
              row.options[i].selected=true;
              }
              }
              </script>

              and this in the submit button

              <input type=submit.... .onClick="selec tAll(this.form. selectedList)">

              that should do the trick (also)


              Comment

              • Ike

                #8
                Re: on submit, select all

                Oh yes....Iwas tring to do it onsubmit=...but s/b onClick=.... ty

                "kaeli" <tiny_one@NOSPA M.comcast.net> wrote in message
                news:MPG.1a5b7a 8f4a29d2ae989a5 6@nntp.lucent.c om...[color=blue]
                > In article <H1iIb.15401$IM 3.6041@newsread 3.news.atl.eart hlink.net>,
                > rxv@hotmail.com enlightened us with...[color=green]
                > > Its a drag and drop control. Elements are dragged into or out of it. I[/color][/color]
                want[color=blue][color=green]
                > > to select it all before submit is hit.
                > >[/color]
                >
                > Well, assuming the user has javascript enabled, which I assume they must
                > for the drag and drop to work, you can just make it a mutli-select and
                > then iterate through the options and set selected to true for each one.
                > You cannot do this before submit is hit - you do it in the onClick of
                > the submit button, before the event is propagated to the onSubmit
                > handler.
                >
                > See McKirahan's reply.
                >
                > --
                > --
                > ~kaeli~
                > The more ridiculous a belief system, the higher probability
                > of its success.
                > http://www.ipwebdesign.net/wildAtHeart
                > http://www.ipwebdesign.net/kaelisSpace
                >[/color]


                Comment

                Working...