javascript - Get html checkbox list checked values to a hidden field -


How to obtain the checked checkbox ID in a hidden variable?

I am getting this error

  Syntax error: non-end string string Verbatim test = $ ('input [name = \' data-grid_kac [] \ '). Val (); The   

data-grid_c0 checkbox is the name of the array.

  & lt; Input type = "checkbox" name = "Data-grid_c0 []" id = "data-grid_code_1" value = "1" & gt; & Lt; Input type = "checkbox" name = "data-grid_kack []" id = "data-grid_code_2" value = "1" & gt; & Lt; Input type = "checkbox" name = "data-grid_kac []" id = "data-grid_code" "value =" 1 "& gt;   

Below I have written jquery code. Click on (check the function ')' at the top of the file (function () {var atLeastOneIsChecked = $ ('Input [name = \ "data-grid_c0 [] \"]: check' ) Length = gt; var test = $ ('Input [name = \' data-grid_kac [] \ '). Val (); Warning (test); if (! Lightenis checked) {Warning (' Please choose to delete a record ');} and if (window confirmation (' Are you sure to record Do you want to delete it? ') {Document GetElementById (' search-form '). Action =' index.php? R = device / bulk delay 'document; getElementById (' search-form '). Submit () ;}});

I want the value of data-grid_c0 to be assigned to selected devices hidden area. = "hotel search / hotel search" method = "post" & gt; & lt; input id = "selected device" type = "hidden" value = "" name = "selected device "/> Gt; & Lt; Id = "deleteall-button" class = "btn btn-primary" & gt; Bulk Remove & lt; / A & gt; & Lt; / Form & gt;

Then with php I will be able to delete and delete the following,

  // check box if (isset ($ _ POST [ SelectedDevices']) {// data-grid_c0 $ del_camps = $ _POST ['Selected Devices']; // data-grid_c0 $ model_camp = new device; Foreign currency ($ del_camps as $ _camp_id) {$ model_camp-> gt; DeleteByPk ($ _ camp_id); }}    

You are shutting down ] and Val ();

/ P>

should be

var test = $ ('input [name = \' data-grid_c0 [ ] \ ']'). Val ();

As others have said, you do not necessarily have to avoid these internal quotes.

var test = $ ('input [name = "data-grid_c0 []"]'). Val ();

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -