Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting checked checkbox values and form input value using jquery ajax submit
    text
    copied!<p>i'm implementing an appilication in which one module contains search method, we get the list of people in table, here is the code for it.</p> <pre><code>&lt;table class="table table-striped table-bordered table-hover" id="sample_3"&gt; &lt;div class="modal fade" id="sms" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt; &lt;div class="modal-dialog"&gt; &lt;div class="modal-content"&gt; &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&lt;/button&gt; &lt;h4 class="modal-title"&gt;Compose Sms&lt;/h4&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;div class="form-group"&gt; &lt;label&gt;Message&lt;/label&gt; &lt;textarea class="form-control" rows="3" name="smsmessage"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button type="button" class="btn blue"&gt;Send Sms&lt;/button&gt; &lt;button type="button" class="btn default" data-dismiss="modal"&gt;Close&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- /.modal-content --&gt; &lt;/div&gt; &lt;!-- /.modal-dialog --&gt; &lt;/div&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class="table-checkbox"&gt; &lt;input type="checkbox" class="group-checkable" data-set="#sample_3 .checkboxes"/&gt;&lt;/th&gt; &lt;th&gt;Surname&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Gender&lt;/th&gt; &lt;th&gt;Town&lt;/th&gt; &lt;th&gt;Mobile No&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php if($numrows!= "0") { while($result = mysql_fetch_array($query,MYSQL_ASSOC)){ ?&gt; &lt;tr class="odd gradeX"&gt; &lt;td&gt;&lt;input type="checkbox" class="checkboxes" value="&lt;?php echo $result['mobileNo'];?&gt;" name="numbers"/&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $result['surname']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $result['name']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $result['sex']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $result['preTown']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $result['mobileNo']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="details.php?id=&lt;?php echo $result['id'];?&gt;" class="btn btn-xs green"&gt;&lt;i class="fa fa-search"&gt;&lt;/i&gt; View&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="editdetails.php?id=&lt;?php echo $result['id'];?&gt;" class="btn btn-xs blue"&gt;&lt;i class="fa fa-edit"&gt;&lt;/i&gt; Edit&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp&lt;a class="fancybox-button fancybox.iframe btn btn-xs purple" href="singlesms.php?number=&lt;?php echo $result['mobileNo'];?&gt;"&gt;&lt;i class="fa fa-envelope"&gt;&lt;/i&gt; Send Sms&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } } else { ?&gt; &lt;tr&gt; &lt;td&gt;No Records Found&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>now if i click submit button, i want only those values to be sent which are selected by checkbox. i want the checkbox values and input:smsmessage to be sent through jquery ajax submit. i have implemented a code but it just uses the checkbox values, i want the input value to be passed through ajax post. here is the what i have implemented </p> <pre><code> $('.btnadd').click(function(){ var checkValues = $('input[name=numbers]:checked').map(function() { return $(this).val(); }).get(); $.ajax({ url: 'loadmore.php', type: 'post', data: { ids: checkValues }, success:function(data){ } }); }); </code></pre> <p>Can u please suggest how to send the input:smsmessage also to this post method. here is the bulksms.php </p> <pre><code> $success="0"; $message=$_POST['smsmessage']; if($message="") { echo "Please Provide Details Correctly"; } foreach($number as $_POST['numbers']) { $parameters['mobilenumber']=$number; $parameters['message'] = $message; if(api_connect("demo","demo@123",$parameters)) { $success="1"; } } if($success=="1") { echo "SMS Sent to all selected people"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload