Current location: Hot Scripts Forums » General Web Coding » JavaScript » using a for statement that collects hidden fields for calculations


using a for statement that collects hidden fields for calculations

Reply
  #1 (permalink)  
Old 10-19-03, 08:44 PM
dv6cougar dv6cougar is offline
New Member
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
using a for statement that collects hidden fields for calculations

i have this down for the most part now, however, i cannot figure out how I can grab all the prices while it's looping.

so i have the values maybe 1, 4, 450 and 350, the total should be 805.

here's my script, any help is greatly appreciated.

Code:
<script language="javascript">
	function compute_first(f) {
										var msg = '';
										var hidden_fields = '';
										var price_array = new Array(f.length);
											for(var i = 0; i < f.length; i++) {
												var e = f.elements[i];
												
												if(e.type == "hidden") {
													
													hidden_fields += '\n' + e.name + ' with value of ' + e.value;
													
													var totalled = e.value;
													var totald += parseFloat(totalled) + parseFloat(totalled);
													
												}
											}
											
											hidden_fields += '\n\n total = ' + totald;
											
											
											msg += 'The following fields are hidden in form f1:\n\n';
											msg += hidden_fields;
											
											document.f1.final_pr.value = totald;
											var shipping = parseFloat(<? echo $final_ship; ?>);
												var ship_total = parseFloat(totald) + parseFloat(shipping);
											document.f1.final_shipping.value = shipping;
											document.f1.final_charge.value = ship_total;
												
									}
									
							</script>
i have tried mahy different routes to there may be a few unnecessary variables set and such in the script that are not used.

i have called alert(msg); to see what goes on here, and the prices are going up from e.value correctly in that, but not when i go to add them.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing array to hidden fields in form on next page? seala ASP 2 09-04-03 02:40 PM


All times are GMT -5. The time now is 11:09 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.