How To Retrieve The Value Of A "Notes" Radio Button In A Javascript Code

If Javascript is useful to integrate in a Domino application, difficulties comes very quickly when you want to use values calculated, or entered by a user, in a field and Javascript. This problem is clear : on one hand, javascript is "written" when the page is generated by Domino and sent to the browser and on the other hand, fields are filled only when the user will do that. So, how modify the code of a javascript depending of a field value if it's yet written ? The solution is to use the field name twice in the same form. Once it will be used to name a "Notes" field, and twice to name an HTML Form written in the same page. In the example below, the problem was to use a radio button to select a picture to show, and to store the choice for a future usage. This problem comes very often, for instance when a user wants to choose a tool in a catalog, or if he wants to configurate his own web portal. The example lets the user choosing a picture between 5 and then select it.
In the form, place three fields, hidden from web browsers :

$$HTMLHead will be "computed for display" and will content this code as value :
"&LTscript LANGUAGE=\"JavaScript\">
<!--"[email protected]+
" function rollOver(Tag,Src){
document.images[Tag].src = Src; return;

var pict1 = new Image();
var pict2 = new Image();
var pict3 = new Image();
var pict4 = new Image();
var pict5 = new Image();
pict5.src=\'/icons/picts/pict5.gif\';"[email protected]+
"// -->

TheList is the field where we will define the list of choices for the radio
It will be computed for display too and will content, in our case, this code as
value :
If the value of the list depends on other things in the application, it's
possible to use a dblookup at this place.

Radio1 is a radio button field which is generated by a formula.
The formula will contain "TheList" as value.

Then write this code as "passthru HTML" :
&LTINPUT TYPE="radio" NAME="radio1" VALUE="" onClick="rollOver('picture',.src) ">
for(var i=0; i&LTdocument.forms[0].elements.length;i++) {
var thisRadio = document.forms[0].elements[i];
if(thisRadio.value == "")
thisRadio.checked = true;
&LTimg src="/icons/picts/empty.gif" BORDER="0" NAME="picture" />

this last HTML code will allow the browser to update the choice of the radio

The first Computed Text will contain this code :
_name := @Left(TheList;"|");
_alias := @Right(TheList;"|");
@Implode("&LTINPUT TYPE=\"radio\" NAME=\"radio1\" VALUE=\""+_alias+"\"
onClick=\"rollOver(\'picture\',"+_alias+".src) \">"+_name;"&LTBR>")
It will create the same form, but with the dynamic content.

The second Computed Text will only contain the name of the "Notes" radio button
: radio1
It will allow us to give to the javascript the right selected value.

And to finish, you can add an Action Button Submit with this classical code :
@Command([FileSave]); @Command([FileCloseWindow])
It will allow us to save the document and, then to retrieve the selected value
in the Notes field "radio1".

Dig Deeper on Domino Resources

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...