calculation order

wxdqz

New Member
i don't know how to write the script for calculate the total for price value multiply quantity value. the value is not type in is selected from the drop down list. thanks.

=======

<SCRIPT LANGUAGE="JavaScript">

function calculate(stage2, quantity)
{var stage = temp.options[temp.selectedIndex].value;
var quant = quantity.options[quantity.selectedIndex].value;
var result.value = eval(quant * stage);}

</SCRIPT>

</p>
<form name="doublecombo">
<p>
<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option>event001</option>
<option>event002</option>

</select>
<select name="stage2" size="1">
<option value=http://www.webdeveloper.com/forum/archive/index.php/"300">RM 300</option>
<option value="200">RM 200</option>
</select>
<select name="quantity" size="1">
<option value="1">1</option>
<option value="2">2</option>

</select>
<input name="calculate" type="button" id="calculate" onChange="calculate(stage2, quantity)" value="calculate" >
<input type=TEXT name="result">
</p>

<script>

var groups=document.doublecombo.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group=new Array()

group[0][0]=new Option("RM 300")
group[0][1]=new Option("RM 200")

group[1][0]=new Option("RM 150")
group[1][1]=new Option("RM 80")

var temp=document.doublecombo.stage2

function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options=new Option(group[x].text,group[x].value)
}
temp.options[0].selected=true
}

function go(){
location=temp.options[temp.selectedIndex].value
}
//-->

</script>
</p>
</form>
 
Back
Top