A simple quetion please help

Discussion in 'PHP' started by hallianonline, Dec 9, 2013.

  1. #1
    Hello i have a simple question and i need a simple solution
    I have a javascript file named a pricing.js which contains this content in it


    var price_arr = new Array('$ 16.95','$ 30.95','$ 49.95','$ 70.95','$ 99.95','$ 109.95','$ 139.95','$ 155.95','$ 199.95','$ 460.95');
    Code (markup):
    but i want to to update this part of javascript file using PHP so please help me in this how can i update this part of the content from javascript file using php?



      '$ 16.95','$ 30.95','$ 49.95','$ 70.95','$ 99.95','$ 109.95','$ 139.95','$ 155.95','$ 199.95','$ 460.95'
    Code (markup):
     
    Solved! View solution.
    hallianonline, Dec 9, 2013 IP
  2. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #2
    Just have a PHP script print the JavaScript and instead of linking to the .js file link to the .php (or whatever the file name is).
     
    NetStar, Dec 9, 2013 IP
  3. andrewhoward123

    andrewhoward123 Active Member

    Messages:
    149
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    50
    #3
    Its very simple just change the file name from .js to .php and change the code from JavaScript to php script..If you know php then you can easily do this....
     
    andrewhoward123, Dec 9, 2013 IP
  4. hallianonline

    hallianonline Active Member

    Messages:
    104
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Yes i know it but i am not an expert so thats why asking to review this suggestion if it looks like professional and easy too
     
    hallianonline, Dec 10, 2013 IP
  5. #5
    Write the javascript code in your PHP file or rename the .js file to .php, then whichever part you want to replace with PHP code simply insert '<? echo $mystring; ?>' and any code you wish to include. This will work fine.
     
    DeanIM, Dec 10, 2013 IP