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

This Content Component encountered an error
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 :
"<script LANGUAGE=\"JavaScript\">
<!--"+@Newline+
" 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();
pict1.src=\'/icons/picts/pict1.gif\';
pict2.src=\'/icons/picts/pict2.gif\';
pict3.src=\'/icons/picts/pict3.gif\';
pict4.src=\'/icons/picts/pict4.gif\';
pict5.src=\'/icons/picts/pict5.gif\';"+@NewLine+
"// -->
</script>"

TheList is the field where we will define the list of choices for the radio
button.
It will be computed for display too and will content, in our case, this code as
value :
"first|pict1":"second|pict2":"third|pict3":"fourth|pict4":"fifth|pict5"
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" :
<INPUT TYPE="radio" NAME="radio1" VALUE="" onClick="rollOver('picture',.src) ">
<SCRIPT>
for(var i=0; i<document.forms[0].elements.length;i++) {
var thisRadio = document.forms[0].elements[i];
if(thisRadio.value == "")
thisRadio.checked = true;
}
</SCRIPT>
<p>
<img src="/icons/picts/empty.gif" BORDER="0" NAME="picture" />
</p>

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

The first Computed Text will contain this code :
_name := @Left(TheList;"|");
_alias := @Right(TheList;"|");
@Implode("<INPUT TYPE=\"radio\" NAME=\"radio1\" VALUE=\""+_alias+"\"
onClick=\"rollOver(\'picture\',"+_alias+".src) \">"+_name;"<BR>")
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".
This was first published in November 2000

Dig deeper on Domino Resources

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close