NOOB : How do I DOM? I have a variable in PHP I need to call in a javascript

Very New; I have taken a look at 5 of the posts on this site that are related to my question and they all seemed great but I must be missing something as none work.

I have a PHP page, the part of the page I care about is :

input name=“amt_bidder_paid” type=“text” id=“amt_bidder_paid” value=“115.00” size=“12” maxlength=“12” onChange=“document.bidder_paid.amt_paid.focus();”

Currently we have this value stuffed with the number 115 just to make things easier. Later on the page we have a “Pay Now” button. Something that has been done 1500000 million times. It’s code is :


        "pk": "this is a long string number that is our pk; this part works great ignore this line",
        "amount": "3.50"


This function makes the value 3.50 and that is great for just stuffing the field and it works, cool! But I need it to actively sync to the field above. None of my attempts work. I’ll list a few tries. Not only do they not work, but usually the entire button goes away.

  1. “amount”: “[amt_bidder_paid]”
  2. “amount”: “<?php $total_due ?>” **This is a variable that reads from the value of the input in another area of the PHP, it works great; tried pulling it into the JS to see if it would act any different.
  3. “amount”: “$(”#amt_bidder_paid").val()" **Found this code didnt work
  4. also tried writing it along these lines
function saveCertificate() {

    alert("Hello World!");    

      jsvar = "<?php echo $name; ?>";

    alert("name = " + jsvar);    


from another post on this site but to no avail. Am I just missing some syntax? This script is throwing me a loop and I’m sure its some nooby mistake.

Nevermind: The fix follows…

    "amount": "<?php echo $total_due ?>"

This works like a champ. I’m a fool.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.