Note that there are some explanatory texts on larger screens.

plurals
  1. POI want to pass a jquery variable to a PHP page, sometimes i am getting the varible and sometimes not
    text
    copied!<p>I have a PHP page named logo_design_3.php. I have used Jquery to post the variable "grand_total" to another page named logo_design_3_sql.php. But unfortunately sometimes i'm getting that variable on the next page and sometimes not. Any idea where i'm doing wrong?</p> <p>Here is the snippet of logo_design_3.php page:</p> <pre><code>&lt;script type="text/javascript"&gt; function load1() { document.getElementById('hide2').style.display = 'none'; return false; } function toggle() { document.getElementById('hide1').style.display = 'none'; document.getElementById('hide2').style.display = ''; document.getElementById('hidrad').checked = 'true'; document.getElementById('silver').checked = false; document.getElementById('bronze').checked = false; document.getElementById('gold').checked = false; } function load2() { document.getElementById('hide1').style.display = ''; document.getElementById('hide2').style.display = 'none'; } &lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var grand_total = 0; $("input").live("change keyup", function() { $("#Totalcost").val(function() { var total = 0; $("input:checked").each(function() { total += parseInt($(this).val(), 10); }); var textVal = parseInt($("#min").val(), 10) || 0; grand_total = total + textVal; return grand_total; }); }); $("#next").live('click', function() { $.ajax({ url: 'logo_design_3_sql.php', type: 'POST', data: { grand_total: grand_total }, success: function(data) { // do something; } }); }); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; function validate() { var num = document.getElementById("min").value; var num = parseInt(num, 10); if (num &lt; 299) { document.getElementById("min").value = "299"; alert("Minimum Amount Should be 299"); } } </code></pre> <p></p> <pre><code>&lt;/head&gt; &lt;body onLoad="load1()"&gt; &lt;div id="wrap"&gt; &lt;div class="main-container internal"&gt; &lt;div class="main wrapper clearfix section"&gt; &lt;article&gt; &lt;section&gt; &lt;h1&gt;Step 3. Contest details&lt;/h1&gt; &lt;h2&gt;Create a contest that attracts the right designers to your brief.&lt;/h2&gt; &lt;p&gt;We've got the largest design community online so it's important to create a contest that attracts the kinds of designers you want to work on your brief.&lt;/p&gt; &lt;div id="form"&gt; &lt;form method="post" id="logoform3" action="logo_design_3_sql.php"&gt; &lt;label&gt;What design package do you want?&lt;/label&gt; &lt;br&gt;All packages come with a 100% money-back guarantee and you own full copyright to the final design. &lt;br&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt; &lt;input type="radio" class="radio" name="b" onClick="load2()" value="299" id="bronze"&gt; &lt;label&gt;Bronze - $299&lt;/label&gt; &lt;br&gt;Get lots of great designs at a great price &lt;br&gt; &lt;li style="list-style:circle"&gt;Expect around 30 designs&lt;/li&gt; &lt;/p&gt; &lt;p&gt; &lt;input type="radio" class="radio" name="b" onClick="load2()" value="499" id="silver"&gt; &lt;label&gt;Silver - $499&lt;/label&gt; &lt;label class="block badge"&gt;Most popular&lt;/label&gt; &lt;br&gt;Attract great designers and get priority support &lt;br&gt; &lt;li style="list-style:circle"&gt;Your project will be shown to designers before bronze projects&lt;/li&gt; &lt;li style="list-style:circle"&gt;Expect around 60 designs&lt;/li&gt; &lt;/p&gt; &lt;p&gt; &lt;input type="radio" class="radio" name="b" onClick="load2()" value="799" id="gold" checked="true"&gt; &lt;label&gt;Gold - $799&lt;/label&gt; &lt;label class="block badge"&gt;Work only with our top designers&lt;/label&gt; &lt;br&gt;Work only with our most talented designers and receive 1-on-1 support &lt;br&gt; &lt;li style="list-style:circle"&gt;Only our best designers can participate to ensure top quality&lt;/li&gt; &lt;li style="list-style:circle"&gt;A dedicated account manager will guide you to the best result possible&lt;/li&gt; &lt;li style="list-style:circle"&gt;Expect around 60 designs of the highest quality&lt;/li&gt; &lt;/p&gt; &lt;a onclick="toggle(); event.preventDefault();" href="#" style="text-decoration:none;border-bottom:1px dotted blue;" id="hide1"&gt;I want to create a custom package&lt;/a&gt; &lt;br&gt; &lt;div id="hide2"&gt; &lt;p&gt; &lt;input type="radio" class="radio" name="bbb" id="hidrad" checked="true" id="name_ur_price" value="0"&gt;Name your price: &lt;input type="number" width="10px" style="background:#ccc; border:1px solid #ccc !important;" id="min" min="299" name="min" onChange="validate();" id="name_your_price" name="name_your_price"&gt;.00($299 minimum) &lt;br&gt; &lt;/p&gt; &lt;/div&gt; &lt;label&gt;Contest preferences&lt;/label&gt; &lt;br&gt; &lt;input type="checkbox" name="" value="39.00" align="middle" id="private_contest" name="private_contest"&gt; &lt;label&gt;Make your contest private (+$39.00)&lt;/label&gt; &lt;br&gt;Your contest will be hidden from search engines and the general public. Only members of the Square Designs community can see your contest and they must agree to a Non-Disclosure Agreement (NDA) to see the details. We provide a standard template for the NDA or &lt;a href="" onclick="document.getElementById('upload').click(); return false"&gt; you can upload your own(as a PDF).&lt;/a&gt; &lt;br&gt; &lt;input type="file" id="upload" name="upload" style="visibility: hidden; width: 1px; height: 1px" multiple /&gt; &lt;label id="design_dura" style="left:!important"&gt;How quickly do you need your design?&lt;/label&gt; &lt;br&gt; &lt;br&gt; &lt;input type="radio" name="c" value="0"&gt; &lt;label&gt;Standard 7 days (FREE)&lt;/label&gt; &lt;br&gt; &lt;input type="radio" name="c" value="39" id="days_3"&gt; &lt;label&gt;In 3 days(+$39.00)&lt;/label&gt; &lt;br&gt; &lt;input type="radio" name="c" value="59" id="days_2"&gt; &lt;label&gt;In 2 days(+$59.00)&lt;/label&gt; &lt;br&gt; &lt;label&gt; &lt;input type="radio" name="c" value="79" id="days_1"&gt;In 24 hours(+$79.00)&lt;/label&gt; &lt;h2&gt;TOTAL :&lt;/h2&gt; &lt;p&gt; &lt;input type="text" name="Totalcost" id="Totalcost" style="background:#f5f5f5; border:none; outline:none; box-shadow:none; font-size:18px;" disabled/&gt; &lt;br&gt; &lt;/p&gt; &lt;input type="submit" class="sumit-styled" value="Next" style="margin-left:-15px;" id="next" name="next"&gt; &lt;input type="submit" class="sumit-styled" value="Save Now" style="margin-left:-15px;" id="save" name="save"&gt; &lt;/form&gt; &lt;/div&gt; &lt;/section&gt; &lt;aside&gt; &lt;img src="img/slide2_2.png" webstripperwas="img/slide2_2.png" alt="mockup" /&gt; &lt;p&gt;&lt;em&gt;Donec sed odio dui. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.&lt;/em&gt; &lt;/p&gt; &lt;/aside&gt; &lt;/article&gt; &lt;!-- END MAIN --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And this is from logo_design_3_sql.php page:</p> <pre><code>&lt;?php include ( "config.php"); $total=$_POST[ 'grand_total']; $sql="INSERT INTO form2 (total)VALUES('$total')" ; if($total&gt;0) { $res = mysql_query($sql); } if($res) { echo "&lt;script&gt; window.location.replace('logo_design_4.php')&lt;/script&gt;"; } else { echo "&lt;script&gt; window.location.replace('logo_design_3.php')&lt;/script&gt;"; } ?&gt; </code></pre> <p>I have issue regarding -> window.location.replace('logo_design_4.php') too. Even if $total is properly inserted in the table, the page that get navigated after insertion is "logo_design_3.php". Why so?</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