Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very stupid question

Status
Not open for further replies.

frippel

IS-IT--Management
Oct 3, 2002
8
0
0
BE
I'm trying the following elment to work

function CalculateTotal(frm)

if I do

alert(frm) I get sumtotal3

now later in this script I would like the following.

documnet.form.frm.value=total

but it gives me error that frm is still unknown, so it did not replace frm for sumtotal3, which it should have done
 
The first alert implies that you're passing a form element's value into the CalculateTotal function. Yuo then go on to imply that your later code is expecting frm to be a real form element.

You also don't say whether the later line is in the CalculateTotal function or not - and if it isn't, "frm" wouldn't be in scope anyway.

Perhaps you can check these out, and if you're still having problems, post your complete code, as well as the lines that call all the functions.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
ok realy hard to explain but here I go.

Dynamic generated form.

<input onClick='var aar=document.banza.prijsa" + row_no +".name; CalculateTotal(aar);' value='bereken' class='type1c' type='button'>

this way is was able to retrieve the form field name

which can be sumtotal1, sumtotal3, sumtotal..., sumtotal999,...

so the whole point is to get the field name to my external java script.

There is would like to do the following
function CalculateTotal(frm) {
var order_total = 0

// Run through all the form fields
for (var i=0; i < document.banza.elements.length; ++i) {

// Get the current field
form_field = document.banza.elements

// Get the field's name
form_name = form_field.name

// Is it a "product" field?
if (form_name.substring(0,3) == "box") {


// Get the quantity
item_quantity =form_field.value
item_price = 1

order_total += item_quantity * item_price
}




}
document.banza.frm.value= order_total.toFixed(2);


--> where frm is actually sumtotal1, or ...2 or ...99 based on the frm value
 
Is this thread now dead, seeing as you're asking a similar question in thread216-1432657, or do you still need help with this?

If the former, why start a new thread when this one was not resolved?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top