php - Get array elements dynamically based on checkbox checked? -
i've got problem can't solve. partly because can't explain right terms. i'm new sorry clumsy question.
below can see overview of goal.
i have products along check boxes.if checked check box index value should store in new array(should perform push() operation here),if in case again unchecked check box means should perform pop() operation.
<form method="post"> <input type="checkbox" name="options[]" value="politics"/> politics<br/> <input type="checkbox" name="options[]" value="movies"/> movies<br/> <input type="checkbox" name="options[]" value="world "/> world<br/> <input type="submit" value="go!" />
may 1 duplicate question give me sorry
any ideas ?
you're using check-boxes, can't use pop, since might unchecked in different order.
so maybe use jquery store link javascript object on dom check-box object using .data()
way can match object later using loop , use .splice()
remove array.
edit 1: want validate state of check-box?
if (document.getelementbyid('mycheckbox').checked){ myarray.push(data); }
Comments
Post a Comment