views:

259

answers:

3

I'm currently working on a Lotus Notes solution. We're just using Web forms so client side operations are done via Javascript.

What I want to accomplish is to reset a Group of Radio Buttons. There are 3 possibilities and I want to choose none. (A 'none of them' possibility would be preferable, I know but we are required to reset them)

I currently use:

//Unchecks a single group of Radio Buttons
//groupname - the name attribute of the group which selection needs to be unchecked
function clearRadioButtonGroup(groupName) {
    for(i=0;i<document.forms[0].elements[groupName].length;i++) {
                 document.forms[0].elements[groupName][i].checked = false;
            }
 }

The problem with this routine is, the Radiogroup gets reset, but on a form submit the old value gets submitted. Any suggestions?

+1  A: 

Are you certain that the old value is actually being submitted? Perhaps it just isn't being updated (erased) in the NotesDocument you're editing? Just a hunch...

BTW, you can download a program called Fiddler that will let you inspect the HTTP POSTs, and you can confirm that the POST data doesn't contain any values for that radio button group. That might help narrow down the problem.

Ken Pespisa
This may also be the problem. I want to erase the value from the document. So how may I change the Javascript call to erase the Data from the Document?Will try out Fiddler tomorrow at work, thanks!
David Klein
So, finally had time to try it out. The old values get POSTed again after clearing the radio fields.
David Klein
+1  A: 

The problem is that clearing the radio buttons make no information about them appear in the submitted form data, and Domino seems to interpret that as no change to the field rather than clear the field.

I haven't found any solution to this I really like, but I can think of two options:

  1. Change the radio buttons to include a no choice option.

The alternative is a bit clumpsy:

  • Add an editable field to the form to use as a flag, hide it from the web browser with css.
  • Have clearRadioButtonGroup also set the flag field to something.
  • Have the onChange event of the radio buttons clear the flag field.
  • In a WebQueryOpen agent, set the radio buttons field to empty if the flag field is non-empty.

Another alternative could be to uses some clever javascript/css trick to hide the no choice option and have clearRadioButtonGroup simply set that choice.

Anders Lindahl
Using an agent to clear the radio groups on submit now, works like a charm :)
David Klein
+2  A: 

What version of Domino are you using? Since 7.x (I think) a %%Surrogate field gets generated as a hidden field in your HTML that you'll be able to reset, so after deselecting all of the radio button options, you can then clear out the %%Surrogate field and you should then avoid having to select a "None of the above" option.

Matt

Matt White
We're using Domino 8. So I'm trying your suggestion out at the moment, thanks!
David Klein
mh, could you be so kind and post an example of an method to reset the Surrogate Field?I searched the Web and found http://www.codestore.net/store.nsf/unid/BLOG-20060609/ as an idea. To print the value of the Surrogate field works, but altering it fails in firefox (field is undefined?)Thanks so far! Gonna rephrase the question
David Klein