Manage Learn to apply best practices and optimize your operations.

Select a value in a dialoglist and then check (in onchange event)

Select a value in a dialoglist and then check (in onchange event) if a certain field in the document of the selected value.

Select a value in a dialoglist and then check (in onchange event) if a certain field in the document of the selected value, for example 'status', is OK.
Example:
PROBLEM

A first dialoglist with the product ID's of a productcatalogue : DialogList1 Code: (use formula for choices)

Existing := @DbLookup("";"":""; "ProductView"; keyvalue ; 4 );
Products := @If(@IsError(Existing) ; ""; "":Existing);
Products;

When the user selects a product (ID) we want to check immediately if the status of that product is not 'Sold Out', and if necessary, give an alert back.

The problem is, we can't access the server side to retrieve the status with javascript!

SOLUTION:
We create a second dialoglist (DialogList2) with exact the same formula (accessing the same view), but with another column retrieved:

Code:

Existing := @DbLookup("";"":""; "ProductView"; keyvalue ; 5 );
Status := @If(@IsError(Existing) ; ""; "":Existing);
Status;

Attention! This dialoglist should not be seen by users, but when you hide it, javascript doesn't recognize it anymore as being a dialoglist.

There is a little workaround for this : put in the HTML Attributes of the field: "style=" width:0;"" Now this field is also hidden and we can keep on using it by javascript !

So we have exact the same number of values in the two dialoglists (because they have the same dblookup formula, except the columnnr retrieved). No we can use the selectedindex of the first dialoglist to retrieve the corresponding value in the second dialoglist

Code: Code (ONCHANGE event of the first dialoglist) :

i = document.forms[0]. DialogList1.selectedIndex;

//Check if the second dialoglist exists
if ( document.forms[0]. DialogList2 != null  ) {
	var StatusValue = document.forms[0]. DialogList2.options[i].text;
	if (   StatusValue == "Sold Out"   ) {
		alert('Attention ! The product is sold out' )
	}
}
 
This was last published in March 2002

Dig Deeper on Domino Resources - Part 5

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

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 ...

SearchDataCenter

SearchContentManagement

Close