tags:

views:

307

answers:

1
  1. Check client side that any 2 out of three fields have been completed before allowing submision of a form
  2. Show/hide data capture fields based on the value of a check box (all client side)?
+1  A: 

Apex 4.0 has the new feature called Dynamic Actions that can perform Javascript and AJAX processing that you define declaratively, i.e. without having to write any (or much) Javascript.

1) Check client side that any 2 out of three fields have been completed before allowing submision of a form

You can create a Dynamic Action that fires on page submit, performs a test, and depending on whether the test returns TRUE or FALSE cancels the submit. However, from my understanding of Dynamic Actions (which you can try out yourself at http://tryapexnow.com) in this example the condition to test would be a Javascript expression like this:

($v('P1_FIELD1') != '' && $v('P1_FIELD2') != '')
|| ($v('P1_FIELD1') != '' && $v('P1_FIELD3') != '')
|| ($v('P1_FIELD2') != '' && $v('P1_FIELD3') != '')

(I hope I have that syntax correct.)

2) Show/hide data capture fields based on the value of a check box (all client side)

This can be done without writing any Javascript, using a Dynamic Action. Assuming the checkbox value is 'Y' when checked then the Dynamic Action's attributes would be something like:

Event:       Change
Item:        P1_CHECKBOX
Condition:   Equal To
Value:       Y
True Action: Hide Item(s)
  Items: P1_FIELD1, P1_FIELD2, P1_FIELD3
False Action: Show Item(s)
  Items: P1_FIELD1, P1_FIELD2, P1_FIELD3
Tony Andrews
Great answer thanks.
g_g