Trying to do a 'watcher' command in VFE for a form. I have radio buttons to set numeric values for questions (there will be 17 questions), but am struggling to build the watcher commands.
The radio buttons assign to document.dcommq1, document.dcommq2, etc.. with the goal that if all buttons are set (not blank, or ""), then compute the total score to document.dcommtotal and write all answers to the respective OBS codes.
I did the following:
/* watcher expression to set COMM Total */
{
!if (document.dcommq1<>"" and document.dcommq2<>"") then
document.dcommtotal = val(document.dcommq1 + val(document.dcommq2)
obsnow("COMMQ#1",document.dcommq1)
obsnow("COMMQ#2",document.dcommq2)
obsnow("COMMTOTAL",document.dcommtotal)
else
document.dcommtotal =""
endif
}
But, nothing seems to be happening. So, I am confused.
You are missing a parenthesis in this line after the first variable
document.dcommtotal = val(document.dcommq1) + val(document.dcommq2)
Make sure this is declared somewhere as a form field or just in the code panel
document.dcommtotal
and you might want to convert it to a string somewhere before saving it to an obsterm, I would probably do it here -
document.dcommtotal = str(val(document.dcommq1) + val(document.dcommq2))
Thanks Mike.
A missing ) character. Sometimes you stare at code and miss the obvious.
Ugh.