0

I have a HTML from.

<input type="checkbox" class="checkit" id="10" name="Tid" value="10">
<input type="hidden" id="23" name="Bid" value="23">

The target is: Link checkbox to hidden field, to pass 2 parameters in Ajax.

In OUT I want something like this : Tid:10, Bid:23

Yes, I can put Bid in checkbox name field, but I looking for a clear/professional way to do it.

P.S If I use only checkbox, no problem, I can get all values in serealizearray(), but I need pass 2 values instead of 1.

4
  • 1
    There's no need to use two inputs: <input type="checkbox" class="checkit" data-bid="23" id="tid_10" name="Tid" value="10">. Now use JS to get the values. Commented Jun 1 at 7:59
  • Can I serealize it ? To have it in array like pairs ? Commented Jun 1 at 10:56
  • The problem is when I user multiple checked - checkbox, after I serealize in in js and send to Ajax ! For single checkbox with data-* inside no problem to get data-bid id, but if I checked multiple checkboxes how to link data-bid to one array like pairs ? Commented Jun 1 at 11:19
  • Solved. I get attr() of data-* and put all this to array, after I pass it to ajax Commented Jun 1 at 13:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.