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
$("#graball").live('click',function(event) { event.preventdefault(); var foo = ""; $('#selectright :selected').each(function(i, selected){ foo = foo + $(selected).text() + " "; }); alert(foo); });
Comments
Post a Comment