Click to See Complete Forum and Search --> : Need help just starting javascript


wrathdh
01-11-2003, 10:26 PM
I am having a problem getting a numerical variable to be recognized as a string variable.

Eg.

<script language=javascript><!--
var weight = 3
function goldprice(){
var price
var goldcost = 350
price = goldcost * weight
}
-->
</script>

<INPUT type="hidden" name="postmode" value="SINGLEPOST">
<span>7 inch SS Box</span><br>
<select name="order">
<option value="">Choose Weight

<script language=javascript><!--

goldprice()

document.write('<option value = \"ssboxxlt7----7 Inch Sterling Silver Extra-Light Box Link Chain----')
document.write(price) //doesn't work, but if I put an actual # in it works
document.write('----2----1/">X-Light $')
document.write(price)
-->
</script>

<option value="ssboxlt7----7 Inch Sterling Silver Light Box Link Chain----6.00----2----1">
Light $6.00

khalidali63
01-11-2003, 10:38 PM
Declare your price variable as global not local as u have. it should be next to weight;

var weight = 3;
var price = 0;

Try this.

Khalid

wrathdh
01-13-2003, 01:50 PM
It works perfect now, thanks.
I was also wondering if I could make this a little more secure.
thanks