Javascript in a button vs in JS Header - Syntax error?

Hello,

I am converting an existing Notes form to a Domino form. Things are going well, but there is something that I do not understand and I was hoping someone could explain to me.

The form is a travel expense report for reimbursement.

Basically on the Notes form there existed an action button with this code in it:

@Command([ViewRefreshFields])

When you click this button the form is refreshed on the web. Number fields that are set to show “$” when refreshed show the “$”.

Technically this would work if I left it as is.

I have this bit of JavaScript code in a hotspot button on my form:

_doClick(‘$Refresh’, this,‘_self’, ‘’);

The hotspot is set to “Run” = Web and as Javascript.

I wanted to make things a little easier on the end user. I have code in the JS Header of the form where I am adding up different values.

Here is an example:

function CalcBreakfast()

{

var f = document.forms[0];

var CalcBreakfastSum;



var a = f.Brkfst1.value;

if (a =="")

{

	a = 0;

}

var b = f.Brkfst2.value;

if (b =="")

{

	b = 0;

}

var c = f.Brkfst3.value;

if (c =="")

{

	c = 0;

}

var d = f.Brkfst4.value;

if (d =="")

{

	d = 0;

}

var e = f.Brkfst5.value;

if (e =="")

{

	e = 0;

}

var g = f.Brkfst6.value;

if (g =="")

{

	g = 0;

}

var h = f.Brkfst7.value;

if (h =="")

{

	h = 0;

}

CalcBreakfastSum = parseFloat(a)+parseFloat(b)+parseFloat(c)+parseFloat(d)+parseFloat(e)+parseFloat(g)+parseFloat(h);

f.Breakfast.value = CalcBreakfastSum.toFixed(2);

TotFood();

CalcBal();

}

This code works, but I would like to combine the above function with the Javascript in my action button, but it does not seem to be working.

I created the following function:

function RefreshDocument()

{ document.forms[0]._doClick.value = (‘$Refresh’, this,‘_self’, ‘’);

  document.forms[0].submit(); 

}

I was calling this function at the end of “function CalcBreakfast()”, but nothing is happening.

Can anyone point me in the right direction or see a problem with my code in the JS Header?

Thanks in advance,

E

Subject: I wouldn’t do it this way

I’d call CalcBreakfast() from the onBlur or onChange event of fields Brkfst1, Brkfst2, etc. This way the user gets immediate recalculations as he enters the data. I don’t see a need to refresh the form; just include CalcBreakfast() and submit() in the form’s Save button.