SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: PHP data to JS

  1. #1
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP data to JS

    Hi All,

    I read the Sitepoint Books about PHP and the JS anthology, but cannot integrate the two.
    Here's my problem:

    For the " IDEAL payment engine" for my site I received a Script which needs the order total.

    Snippet:

    Code HTML4Strict:
    [B]<!-- CODE_START -->
    <script type="text/javascript">
    <!-- Begin
    [COLOR="Red"]var Amount = 123;[/COLOR]
    var PSPID = "TESTiDEALEASY";[/B]

    The manual states that I should replace the 123 (red) with the order total (dynamicaly)

    My shoppingcart is coded in PHP and the total is therefore known as $total But if I just paste this into the JS code, I receive an error NaN (not a number)

    So var Amount = $total;

    Does not work.

    What am I doing wrong ?
    Please help

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    type

    A NaN error sounds like a type mismatch. I guess you could use either PHP or the javascript to cast/parse the value to a number.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •