Alejandro Aponte
Alejandro Aponte

Reputation: 11

JavaScript get PHP Variable in URL

How are you? I need some help with javascript

I have this code of WHMCS (http://docs.whmcs.com/Data_Feeds): {literal}{/literal}

{literal} => Run JavaScript in WHMCS Templetes files {/literal} => Finish JavaScript

I need to change the value&currency=1 with the variable in my URL.

For example index.php?currency=4 Have this code: {literal}{/literal}

Can you help me?

Regards, Alex :)

Upvotes: 0

Views: 175

Answers (1)

Sean Bright
Sean Bright

Reputation: 120634

Something like this should do it:

<?php
    $currency = 1;

    if (isset($_REQUEST['currency']) && is_numeric($_REQUEST['currency'])) {
        $currency = intval($_REQUEST['currency']);
    }
?>

<script language="javascript" src="feeds/productsinfo.php?pid=41&get=price&billingcycle=annually&currency=<?= $currency ?>"></script>

Upvotes: 1

Related Questions