Home

Friday, July 29, 2011

How to use PUSH in Javascript

<select name="sub_cat_id" id="sub_cat_id"  multiple="multiple">
                <option value="1">Dhirendra</option>
                <option value="2">Prashant</option>
                <option value="3">Darshak</option>
</select>

var combo1 = document.getElementById("sub_cat_id");
var len = combo1.length
        var i
        var chosen = new Array();
        var j=0;
        for (i = 0; i < len; i++) {
        if (combo1[i].selected) {
        chosen.push(combo1[i].value)
       
        }
        }

No comments:

Post a Comment

rathoddhirendra.blogspot.com-Google pagerank and Worth