Jquery does not collect other data through the form, and outputs array to the back end.

suppose the following is a loop

// <form>  form
<? while ($row = ... { ?>
    <button class="btn-selector" data-id="<?=$row["prod_id"];?>">select this</button>
<? } ?>
// </form>

if there are five prod
, there will be five buttons

.
<button class="btn-selector" data-id="100">select this</button>
<button class="btn-selector" data-id="101">select this</button>
<button class="btn-selector" data-id="102">select this</button>
<button class="btn-selector" data-id="103">select this</button>
<button class="btn-selector" data-id="104">select this</button>

each loop has a button, plus data-id "s prod_id
when the while is not in a form,
how can I know which prod_id he selected?
suppose I press 101102104 (without submit)
how can I throw these three into array to the backend?
who is selected, let"s throw everyone into the backend.
is it true?

Oct.25,2021

bind the click event to button and add an identification of whether to select it in the element, such as $(btn) .toggleClass ('btn-selected');

when you click the submit button, get the element containing the class btn-selected in button , and then traverse and put the data-id into the data

.

ajax request interface and set content-type to application/json

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e98495-46147.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e98495-46147.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?