Simple Machines Community Forum

General Community => Scripting Help => Topic started by: MoreBloodWine on December 31, 2014, 05:35:30 AM

Title: Javascript question...
Post by: MoreBloodWine on December 31, 2014, 05:35:30 AM
<script language="javascript">
var cost = {COST};
var multiplier = 3;
var total = cost*multiplier;
alert(total.toFixed(4))
</script>


Ok, so the math gives me the answer I'm after in an alert but how can I do away with the alert and have the alerts "answer" instead be a variable I can use anywhere on the page to display.

Ex.

$hello = 'goodbye';

Now I can use echo $hello; anywhere on a page to display goodbye.

Ty in advance.
Title: Re: Javascript question...
Post by: Arantor on December 31, 2014, 05:53:41 AM
var total = (cost*multiplier).toFixed(4);

Now you have the variable total you can use.
Title: Re: Javascript question...
Post by: MoreBloodWine on December 31, 2014, 07:11:38 AM
Quote from: Arantor on December 31, 2014, 05:53:41 AM
var total = (cost*multiplier).toFixed(4);

Now you have the variable total you can use.
Ty for that.