pyrogrammer
pyrogrammer

Reputation: 560

unable to shift numeric values from Javascript to php,not using <form>

This value of count is to be transferred to the php page orderdetail.php This is the javascript code that i am using,Please provide the solution.

 
    var count=10;
    $.post('orderdetail.php',{no_of_orders:count},function(){});

The php code i am using is

<?php
    $no_of_orders=$_POST['no_of_orders'];
    echo $no_of_orders; 
?>

Upvotes: 1

Views: 36

Answers (2)

Oluwaseye
Oluwaseye

Reputation: 695

Using jQuery to set the value of the input field with the id myVal. Then you can send the value with the Form

JS/jQuery CODE

var count=10;
$('#myVal').val(count);

HTML/PHP CODE

<form action="orderdetail.php" method="POST">
<input type="hidden" value="" id="myVal" />
<input type="submit" value="Submit">
</form>

Hope this helps

Upvotes: 0

a_man
a_man

Reputation: 304

Why don't you just use the php instead of including javascript for this purpose?

Upvotes: 1

Related Questions