Set value of hidden field based on selection of radio button

Set value of hidden field based on selection of radio button

menhirmenhir Posts: 3Questions: 1Answers: 0

Hi,

Let's say I have two fields in my db; value1 and value1_date

Value for value1 is selected with radio button values Yes | No.
Value for value1_date is hidden field.

When value Yes is selected I want the value of hidden field value1_date to be set to NOW(). If value No is selected, the value1_date will be empty. How can it be done with the editor?

Thanks

Answers

  • ThomDThomD Posts: 334Questions: 11Answers: 43

    Easy. Use the .edit().set() API. Put an onClick event on value1 radio button to trigger the call.

    See this page for an example

    http://editor.datatables.net/reference/api/edit()

  • menhirmenhir Posts: 3Questions: 1Answers: 0

    Thanks for your answer. Unfortunately, I don't really get it because I'm new to DataTables Editor. May I ask you for an example of code? I didn't understand how to use the examples on http://editor.datatables.net/reference/api/edit() for my problem...

    Is it this part of the js file I need to change:

                {
                    "label": "Value 1",
                    "name": "value1",
                    "type": "radio",
                    "def": "No",
                    "options": [
                        "Yes",
                        "No"
                    ]
                },
    

    or is it a separate code part for value1_date I need to add?

This discussion has been closed.