Web Hosting Talk







View Full Version : using SSI generated variables in javascript calculation


conuremom
02-01-2006, 11:12 AM
I need to preface this by saying I'm not a "real" programmer, don't even play one on tv. I'm teaching myself what I need to do as I go along with this project.

I'm producing an HTML formatted "winning bidder" letter for a non-ebay auction site that I am going to be running. The variable data (winner's name, winning bid amount, shipping fee, etc. ) used in the letter is generated by SSI using data inputted on the auction site.

What I'm trying to do is a simple calculation using the output of those SSI variables. I need to calculate a total amount owed by adding together the shipping fee and winning bid amount. The problem arises in that I need to set up variables in javascript using the SSI generated data as the input for the variables.

The SSI generated fields appear in the HTML of the letter encased in HTML comment tags < !-- fieldname-- > (with no spaces of course).

Is there a way to do this in javascript (or any other method--I'm desperate) and if so, would you be so kind as to share that knowledge with me?

NateD
02-01-2006, 09:58 PM
To do this in PHP I do:


<script language="Javascript">
var amount = <?= $variable ?>;

//format and do whatever here
</script>


Remember that server-side code (PHP) gets parsed BEFORE any client-side (Javascript) code.