KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Managing a pop up in a form used for Web serving (contextual mode)
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: July 21, 2000

When using 4D as a Web server in contextual mode, you cannot use choice lists to help users enter correct values and limit the entries to a specific set of values. There can be an easy workaround to that, you can use a pop-up menu to perform the same task.

The example below provides very simple code that populates a pop-up menu based on data extracted from a One table. The code manages the following:


  • It populates the menu with data extracted from a string array.
  • It displays the existing field value in the pop-up when a record is being edited.
  • It displays no field value in the pop-up when a record is being created.
  • It saves the value selected by the user when the record is validated


This code should be placed in the form method of the form used to publish the data.

Cut and Paste the following code example into your own 4D project

Case of
  : (Form event=On Load )
Extract_array
  `Method that creates the array used to populate the pop-up menu
 SORT ARRAY(asPopMenu;>)
 COPY ARRAY(asPopMenu;Pop1)
  `Copying the array into the pop-up array
 If ([Table 1]Name#"")
  `setting the pop-up to existing value
  `if any
 ItemNumber:=Find in array(Pop1;[Table 1]Name)
 Pop1:=ItemNumber
End if
: (Form event=On Validate )
[Table 1]Name:=(Pop1{Pop1})
`Saving the selected value
End case