SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 25th, 2004, 05:12 PM
Bin_P19@hotmail Bin_P19@hotmail is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 Bin_P19@hotmail User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation 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

Reply With Quote
  #2  
Old June 30th, 2006, 11:43 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 471 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 9 m 44 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
all you need to do is make for loops to run and reset for example


var test=new Array()
//lets say it has 50 idems inside
var tester=new Array()
//this has 12

for (var x=0;x<test.length;x++) {test[x]="";}
for (var x=0;x<tester.length;x++) {tester[x]="";}

hope this helped

colton22

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > need to reset an array using a function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway