Saturday, November 1, 2008

[jQuery] Re: Get All Values/Text and Add a ";"

On Nov 1, 11:15 am, Jay <JSpren...@gmail.com> wrote:
> You're using each() to extract the selected options. That will not
> work as written.
> You need to select the child nodes that are <option>'s, See the
> selector below.
> You also need to move the result write after the end of the loop.
>
> <html>
> <head>
> <script src="jquery-1.2.6.min.js" type="text/javascript"></script>
> </head>
> <body>
> <select id="select1" name="select1" multiple="multiple">
>     <option>Flowers</option>
>     <option>Shrubs</option>
>     <option>Trees</option>
>   </select>
>
> <p/>
> </body>
> <script type="text/javascript">
>
> <!--
>
> $( function()
>
> {
>
>  var str = "";
>        $("#select1>option").each(function(){
>            str += $(this).val() + ";";
>        });
>        $("p").text(str);
>
> } );
>
> //-->
>
> </script>
>
> </html>

Thanks very much, bit by bit i'm will going to catch a
jquery(wonderful tool)...

JETM

No comments: