
April 25th, 2004, 05:12 PM
|
|
Registered User
|
|
Join Date: Apr 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
need to reset an array using a function
hi here is the javascript code i wanna reset this array
Code:
<script language="javascript" type="text/javascript">
var Album = new Array();
var Price = new Array();
var Quantity = new Array();
function updateTextSelection(x){
addBill(document.myForm.select.options[x].text,document.myForm.select.options[x].value,document.myForm.quantity.value);
}
function addBill(item,cost,quant) {
Album[Album.length] = item;
Price[Price.length] = cost;
Quantity[Quantity.length] = quant;
var i;
var orderString="";
var bill=0;
var tempPrice=0.00;
for(i=0;i<Price.length;i++) {
tempPrice=0.00;
orderString = orderString + "Quantity :" + Quantity[i]+ '\t'+ Album[i] + ': \t £' + Price[i] + 'p \n';
tempPrice = parseFloat(Price[i]) * Quantity[i]
bill = bill+ parseFloat(tempPrice);
}
document.myForm.itemarea.value = orderString;
document.myForm.totalCost.value = '£' + bill;
calcTotal(document.myForm.quantity.value,bill);
//document.myForm.quantity.value =""
}
function calcTotal(quantity,bill) {
if ((isNaN(quantity))) {
alert('Please select a quantity for item');
}
else {
if (quantity<1 || quantity>5) {
alert('Ticket quantity should be between 1 and 5');
}
else {
var total = '£'+ bill;
document.myForm.totalCost.value =total;
}
}
}
function reset(){
//self.focus()
Quantity=new Array();
Price = new Array();
Album = new Array();
for (var i=1;i<=length;i++){
document.myForm.Quantity.value = ""
document.myForm.Album.value = ""
document.myForm.Price.value = ""
}
}
</script>
Last edited by stumpy : April 27th, 2004 at 06:37 AM.
Reason: Please place code in [code] tags, as per the forums rules
|