I have a sample code:
<input type="hidden" value="" name="stall_id">
<a href='javascript:;' onclick='check(this)' data-id='1'>Add</a>
<a href='javascript:;' onclick='check(this)' data-id='2'>Add</a>
<a href='javascript:;' onclick='check(this)' data-id='3'>Add</a>
My jquery:
function check(tr) {
var id = $(this).data("id");
$(tr).attr("onclick", "uncheck(this)");
$(tr).html('Add');
}
function uncheck(tr) {
var id = $(this).data("id");
$(tr).attr("onclick", "check(this)");
$(tr).html('Remove');
}
How to when check/uncheck, value will auto add on input hidden ?
Ex: <input type="hidden" value="1,3" name="stall_id">
if I had checked two value.