Grab select options with javascript -


i have 2 boxes switch data between each other. default, last box empty , receives items added user, clicking on ">" button.

now, need action grab these items in simple alert via js.

when user add items box on right , click on "grab all" button, needs show alert selected (pushed) items.

here's html:

<form method="get" style="width:400px">                 <select id="selectleft" multiple="multiple" style="float:left">         <option value="1">wood</option>         <option value="2">steel</option>         <option value="3">iron</option>         <option value="4">carbon fiber</option>    </select>   <div class="btns">   <input id="filter_right" type="button" value=" > " />   <input id="filter_left" type="button" value=" < " /> </div>   <select id="selectright" multiple="multiple" style="float:right">    </select>      <input type="submit" value="grab all" />  </form> 

here js fiddle of issue: http://jsfiddle.net/pamde/4/

what can make action on button? or reference grateful.

thanks in advice!

here working example, show has been selected

http://jsfiddle.net/3twan/

$("#graball").live('click',function(event) {             event.preventdefault();             var foo = "";              $('#selectright :selected').each(function(i, selected){               foo = foo + $(selected).text() + " ";             });              alert(foo);         }); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -