Jump to content
  • 0

Set other fields to Null after one field is changed



Hi - I have 4 Virtual fields  in my submission form and ALL virtual fields have Dropdown form elements. When I select a value in one virtual field, I would like to set the other fields to have blank values. So my scenarios,

1. I chose a value(non-null) in cbParamVirtual1, the values in cbParamVirtual2, cbParamVirtual3, and cbParamVirtual4 would be blank or null.

2. I chose a value(non-null) in cbParamVirtual2, the values in cbParamVirtual1, cbParamVirtual3, and cbParamVirtual4 would be blank or null.

3. I chose a value(non-null) in cbParamVirtual3, the values in cbParamVirtual1, cbParamVirtual2, and cbParamVirtual4 would be blank or null.

4. I chose a value(non-null) in cbParamVirtual4, the values in cbParamVirtual1, cbParamVirtual2, and cbParamVirtual3 would be blank or null.

I hope that this would be a simple JavaScript that you can provide. Thank you for the help.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @NeoInJS,


You may try pasting the code snippet provided in an HTML Block.

(Note: Disable the HTML Editor from the Advanced tab, and move the HTML Block to the very bottom).


Note that we can add/remove items in the fields arrayWe can add DataSource fields as well. Just duplicate field lines as needed and put cbParamVirtualn, or the name of your DataSource field.

  var fields = [
   * Do not modify code from beyond this point
  fields = fields.map( function(elem) {
    return document.querySelector('[action*="[@cbAppKey]"] [id*='+ elem + ']');


  function changer(ev) {
    fields.forEach(function(field) {
      if (ev.target.value != '' && ev.target != field)
        field.value = '';


  fields.forEach(function(fff) {
    fff.addEventListener('change', changer);



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...