OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Formio.js get value of select component before and after change

  • Thread starter Thread starter Philiz
  • Start date Start date
P

Philiz

Guest
I use formio javascript library to create my forms and I simply need for a dropdown to get its current value and its previous value on change event.
The challenge here is that the dropdown can be in a datagrid and more dropdowns are added when adding row. Like with this simple form configuration:

Code:
{ display : 'form'
, components: 
  [ { label              : 'Data Grid'
    , reorder            : false
    , addAnotherPosition : 'bottom'
    , layoutFixed        : false
    , enableRowGroups    : false
    , initEmpty          : false
    , tableView          : false
    , defaultValue       : [ { } ] 
    , key                : 'dataGrid'
    , type               : 'datagrid'
    , input              : true
    , components: 
      [ { label     : 'Test drop down'
        , widget    : 'choicesjs'
        , tableView : true
        , data: 
          { values: 
            [ { label: 'Test 1', value: 'test1' } 
            , { label: 'Test 2', value: 'test2' } 
            , { label: 'Test 3', value: 'test3' } 
            ] 
          } 
        , key       : 'testDropDown'
        , type      : 'select'
        , input     : true
} ] } ] }

<p>I use <a href="https://formio.github.io/formio.js/app/sandbox.html" rel="nofollow noreferrer">formio</a> javascript library to create my forms and I simply need for a dropdown to get its <strong>current</strong> value and its <strong>previous</strong> value on change event.<br />
The challenge here is that the dropdown can be in a datagrid and more dropdowns are added when adding row. Like with this simple form configuration:</p>
<pre><code>{ display : 'form'
, components:
[ { label : 'Data Grid'
, reorder : false
, addAnotherPosition : 'bottom'
, layoutFixed : false
, enableRowGroups : false
, initEmpty : false
, tableView : false
, defaultValue : [ { } ]
, key : 'dataGrid'
, type : 'datagrid'
, input : true
, components:
[ { label : 'Test drop down'
, widget : 'choicesjs'
, tableView : true
, data:
{ values:
[ { label: 'Test 1', value: 'test1' }
, { label: 'Test 2', value: 'test2' }
, { label: 'Test 3', value: 'test3' }
]
}
, key : 'testDropDown'
, type : 'select'
, input : true
} ] } ] }
</code></pre>
 

Latest posts

P
Replies
0
Views
1
Paras Chouhan
P
Top