1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Include variable in javascript

Discussion in 'JavaScript' started by floriano, Sep 12, 2019.

  1. #1
    Hello,

    I am newbie in javascript, can anyone help me please?

    I want to add a variable in: var url
    here I want to replace:
    var url = "<?php echo $my_variable; ?>";

    this variable is used in many pages and for each page have a different name... is not fixed variable.

    Thanks in advance for any help !
    SEMrush
    Regards,
    floriano
     
    floriano, Sep 12, 2019 IP
    SEMrush
  2. sarahk

    sarahk iTamer Staff

    Messages:
    25,267
    Likes Received:
    3,442
    Best Answers:
    100
    Trophy Points:
    665
    #2
    That's how its done. Is it not working for you?
     
    sarahk, Sep 13, 2019 IP
  3. floriano

    floriano Well-Known Member

    Messages:
    70
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    113
    #3
    No
     
    floriano, Sep 13, 2019 IP
  4. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    5,948
    Likes Received:
    1,101
    Best Answers:
    22
    Trophy Points:
    400
    #4
    Is the page saved as a .php page?
     
    qwikad.com, Sep 13, 2019 IP
  5. floriano

    floriano Well-Known Member

    Messages:
    70
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    113
    #5
    Yes
     
    floriano, Sep 13, 2019 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    25,267
    Likes Received:
    3,442
    Best Answers:
    100
    Trophy Points:
    665
    #6
    When you view source what do you see?
     
    sarahk, Sep 13, 2019 IP