所以我有2類複選框。獲取複選框值與JS
<input type="checkbox" name="foo" value="val1" />
<input type="checkbox" name="foo" value="val2" />
<input type="checkbox" name="bar" value="val1" />
<input type="checkbox" name="bar" value="val2" />
當複選框被選中我想運行一個jQuery函數將分配兩個變量
var foo = //the values of the checked boxes with the foo name
var bar = //the values of the checked boxes with the bar name
因此,可以說只有第一個複選框被這裏因爲兩者都檢查FOO組中被選中在酒吧組裏。該組值是如下
var foo = val1;
var bar = val1,val2;
什麼是通過共享相同的名稱/班看看,如果他們被檢查,如果這樣的價值添加到字符串的所有複選框進行搜索的最佳途徑?
看到http://stackoverflow.com/questions/416752/select-values-of-checkbox-group-with-jquery – Fortega