Note that there are some explanatory texts on larger screens.

plurals
  1. POprocessing send checkboxes to php ajax
    text
    copied!<p>Right now I am using PHP mailer for a small application I'm making for class, I got it to send properly on the local page i made for it so I know it works by itself </p> <pre><code>function submitForm() { var x; var email = prompt("Please enter your email", "John Doe"); if (email != null) { alert("sent") } $(document).ready(function () { var dataString = $("#form2").serializeArray(); alert(datastring); $.ajax({ type: "POST", crossDomain: true, url: "http://xxxx.xx.xxx/xx/xxx/xxxx/phpmailer.php", data: {dataString: dataString, email: email}, cache: false, async: true, datatype: "json", success: function (data) { $('#result').html(data); } }); return false; }); } </code></pre> <p>What I believe I am doing here is sending a list of id values that are checked to my php script </p> <p>which is doing this </p> <pre><code>$listofnames = array(); //trying to record every name passed into the for each loop $cals = 0; $fat = 0; $chol = 0; $pro = 0; $box = $_POST['dataString']; foreach ($box as $x) { $stmt = $mysqli-&gt;query("SELECT * FROM foo.bar WHERE ItemName = '$x' "); $row = $stmt-&gt;fetch_assoc(); $cals += $row["KCAL"]; $fat += $row["FAT"]; $chol += $row["CHOL"]; $pro += $row["PRO"]; } </code></pre> <p>Calling the script via ajax however doesn't even get me an email back no do i know whether it is actually receiving the string in the right format </p> <pre><code>&lt;form id ="form2" name="form2" method="post" action="" onSubmit ="JavaScript:submitForm()"&gt; &lt;div data-role="collapsible-set"&gt; &lt;div data-role="collapsible" data-collapsed="true" data-theme="a" data-content-theme = "a"&gt; &lt;h3 &gt; Signature Sandwiches&lt;/h3&gt; &lt;input type="checkbox" name="value" id="turkey and provolone panini" class="check"&gt; &lt;label for="turkey and provolone panini"&gt;Turkey and Provolone Panini&lt;/label&gt; &lt;input type="checkbox" name="value" id="corned beef reuben on marble rye panini" class="check"&gt; &lt;label for="corned beef reuben on marble rye panini"&gt;Corned Beef Reuben on Marble Rye Panini&lt;/label&gt; &lt;input type="checkbox" name="value" id="malibu grilled veggie panini" class="check"&gt; &lt;label for="malibu grilled veggie panini"&gt;Malibu Grilled Veggie Panini&lt;/label&gt; &lt;input type="checkbox" name="value" id="southside corned beef" class="check"&gt; &lt;label for="southside corned beef"&gt;Southside Corned Beef&lt;/label&gt; &lt;input type="checkbox" name="value" id="Chipolte Chicken" class="check"&gt; &lt;label for="Chipolte Chicken"&gt;Chipolte Chicken&lt;/label&gt; &lt;input type="checkbox" name="value" id="asiago turkey" class="check"&gt; &lt;label for="asiago turkey"&gt;Asiago Turkey&lt;/label&gt; &lt;input type="checkbox" name="value" id="buffalo chicken sandwich" class="check"&gt; &lt;label for="buffalo chicken sandwich"&gt;Buffalo Chicken sandwich&lt;/label&gt; &lt;input type="checkbox" name="value" id="little italy meatball sub" class="check"&gt; &lt;label for="little italy meatball sub"&gt;Little Itlay Meatball Sandwich&lt;/label&gt; &lt;input type="checkbox" name="value" id="peanut butter and jelly sandwich" class="check"&gt; &lt;label for="peanut butter and jelly sandwich"&gt;Peanut Butter and Jelly Sandwich&lt;/label&gt; &lt;input type="checkbox" name="value" id="Ham and Swiss Sub" class="check"&gt; &lt;label for="Ham and Swiss Sub"&gt;ham and swiss sandwich&lt;/label&gt; &lt;input type="checkbox" name="value" id="Ham and Provolone with Honey Mustard" class="check"&gt; &lt;label for="Ham and Provolone with Honey Mustard"&gt;Ham and Provolone with Honey Mustard&lt;/label&gt; &lt;input type="checkbox" name="value" id="Ham and Swiss Cheese Sandwich on White" class="check"&gt; &lt;label for="Ham and Swiss Cheese Sandwich on White"&gt;Ham and Swiss sandwich on White&lt;/label&gt; &lt;input type="checkbox" name="value" id="thai chicken wrap" class="check"&gt; &lt;label for="thai chicken wrap"&gt;Thai Chicken Wrap&lt;/label&gt; &lt;input type="checkbox" name="value" id="turkey wrap" class="check"&gt; &lt;label for="turkey wrap"&gt;Turkey Wrap &lt;/label&gt; &lt;input type="checkbox" name="value" id="Mediterranean hummus wrap" class="check"&gt; &lt;label for="Mediterranean hummus wrap"&gt;mediterranean hummus wrap&lt;/label&gt; &lt;input type="checkbox" name="value" id="Smokin Turkey Club Sandwiches" class="check"&gt; &lt;label for="Smokin Turkey Club Sandwiches"&gt;Smokin Turkey Club&lt;/label&gt; &lt;input type="checkbox" name="value" id="club sub on white" class="check"&gt; &lt;label for="club sub on white"&gt;Club on on White&lt;/label&gt; &lt;/div&gt; &lt;div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme = "b"&gt; &lt;h3&gt;Breakfest Grill&lt;/h3&gt; &lt;input type="checkbox" name="value" id="scrambled egg" class="check"&gt; &lt;label for="scrambled egg"&gt;Scrambled Egg&lt;/label&gt; &lt;input type="checkbox" name="value" id="Scrambled Eggs with Cheese" class="check"&gt; &lt;label for="Scrambled Eggs with Cheese"&gt;Scrambled Eggs w/ Cheese&lt;/label&gt; &lt;input type="checkbox" name="value" id="sausage patty" class="check"&gt; &lt;label for="sausage patty"&gt;Sausage Patty&lt;/label&gt; &lt;input type="checkbox" name="value" id="applewood bacon" class="check"&gt; &lt;label for="applewood bacon"&gt;Applewood Bacon&lt;/label&gt; &lt;input type="checkbox" name="value" id="pancakes" class="check"&gt; &lt;label for="pancakes"&gt;Pancakes&lt;/label&gt; &lt;input type="checkbox" name="value" id="belgian waffles" class="check"&gt; &lt;label for="belgian waffles"&gt;Belgian Waffles&lt;/label&gt; &lt;input type="checkbox" name="value" id="breakfast sandwich" class="check"&gt; &lt;label for="breakfast sandwich"&gt;Breakfast Sandwich&lt;/label&gt; &lt;input type="checkbox" name="value" id="hash brown potato patty" class="check"&gt; &lt;label for="hash brown potato patty"&gt;hash Brown Potato Patty&lt;/label&gt; &lt;/div&gt; &lt;div data-role="collapsible" data-collapsed="true" data-theme="a" data-content-theme = "a"&gt; &lt;h3&gt; Lunch Grill&lt;/h3&gt; &lt;input type="checkbox" name="value" id="crispy chicken tenders" class="check"&gt; &lt;label for="crispy chicken tenders"&gt;Crispy Checken Tenders&lt;/label&gt; &lt;input type="checkbox" name="value" id="buffalo blue crispy chicken burger" class="check"&gt; &lt;label for="buffalo blue crispy chicken burger"&gt;Buffalo Blue Crispy Chicken Burger&lt;/label&gt; &lt;input type="checkbox" name="value" id="mile high natural beef burger" class="check"&gt; &lt;label for="mile high natural beef burger"&gt;Mile High Natural Beef Burger&lt;/label&gt; &lt;input type="checkbox" name="value" id="Natural Beef Burger" class="check"&gt; &lt;label for="Natural Beef Burger"&gt;Natural Beef Burger&lt;/label&gt; &lt;input type="checkbox" name="value" id="natural beef burger with sharp" class="check"&gt; &lt;label for="natural beef burger with sharp"&gt;Natural Beef Burger w/ Sharp&lt;/label&gt; &lt;input type="checkbox" name="value" id="no other like this veggie burger" class="check"&gt; &lt;label for="no other like this veggie burger"&gt;No Other Like This Veggie Burger&lt;/label&gt; &lt;input type="checkbox" name="value" id="taco chicken burger with guacamole" class="check"&gt; &lt;label for="taco chicken burger with guacamole"&gt;Taco Chicken Burger with Guacamole&lt;/label&gt; &lt;input type="checkbox" name="value" id="texas toast grilled cheese sandwich" class="check"&gt; &lt;label for="texas toast grilled cheese sandwich"&gt;Teaxas Toast Grilled Cheese Sandwich&lt;/label&gt; &lt;/div&gt; &lt;input type="submit" value="Send to email" /&gt; &lt;/form&gt; </code></pre> <p>nothing too out of the ordinary with the form just a collapsable </p>
 

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