I have a form in where a user inputs certain info and they get back some info via Javascript.
I want to pass the info from the Javascript on to another page. Although, in the form which the user inputs in, there is an Input field which I want to pass through to the next screen as well. I know I can pass this Input field through $POST and session, but it's the Javascript fields I'm struggling with.
Here is my form (I'll show one field as to not flood the screen with code):
//I added this hidden field and it stopped my javascript form updating//
<input id="amount" type="hidden">
//===========================================================//
<input class="applyForm-input" id="amount" name="amount" type="text" autocomplete="off" maxlength="6" style="position:relative; left:200px; top:-24px;">
Here is where it is output via Javascript:
<div class="loanForm-totalToBorrow v-number" id="amountdiv">
Here is my Javascript for this particular field:
function updateCost() {
var amount = parseFloat(document.getElementById("amount").value) || 0.00;
delivery = parseFloat(document.getElementById("delivery").value);
if(delivery !='select' && delivery)
{
delivery=parseFloat(delivery);
}
else
{
delivery= 0.00;
}
total = amount + delivery;
fixedrate = total / 100 * 12.2;
grandtotal = fixedrate + total;
document.getElementById("amountdiv").innerHTML = amount.toFixed(2);
Now I know PHP is serverside and Javascript is Client side. So how would I pass this data to a PHP variable.
On my second page, I want to output some of the sessions. An example of one below:
<?php
echo ' <tr class="blah1"> ';
echo ' <td class="blah2">£' . $_SESSION['amountdiv'] . ' </td> ';
echo ' </tr> ';
?>
I've looked through stackoverflow and people mention hidden input fields. Although, when I add these, my Javascript stops working.
input
does not havevalue
.... – Ankur Kumar Mar 15 '13 at 15:16