Good morning,
I would like to understand if and how to set the event of the dropdown to set a certain value of a hidden field.
Is there an example somewhere?
thanks
Hi sanma,
Please explain what you need in more detail as I am not clear.
You can set a default value for any input element by adding it to the form data in the form Load event before the HTML (render form) action.
Bob
shortly. I have to change the value of hidden1 based on the value of dropdown1
if dropdown1 = 0 hidden1 = 'hello'
if dropdown1 = 1 hidden1 = 'bye'
because the value of hidden1 will be passed to the tcpdf
Dropdown commands other events in the form and also an event switcher in which there are various tcpdfs. I can not pass it directly to the tcpdf
Hi sanma,
Could you just change the values in the drop-down to get the same result ?
Otherwise you can use a PHP action after the form submits to set the value.
Or, and most complicated, you could use JavaScript to set the value in the browser.
Bob
With php the problem is solvable but I have very little knowledge of php.
I would like the field to be enhanced without direct interaction from the user but automatically according to other fields of the form and then pass the value of that field to the tcpdf
Hi Could you just change the values in the drop-down to get the same result ?,
Could you just change the values in the drop-down to get the same result ?
Bob
No, because the value of dropdown1 should not be passed to tcpdf but must be passed hidden1.
For now I have solved with the following php code in a custom code of on submit
<?php
switch ($form->data['dropdown1']) {
case '1':
$form->data['hidden1'] = 'one';
break;
case '2':
$form->data['hidden1'] = 'two';
default:
$form->data['hidden2'] = 'zero';
break;
}?>
But I would like to get the same result without php maybe using chronoform events
But WHY can't you just use the dropdown I legitimately don't understand.
Because I send to the tcpdf 8 variables using no more than 2 dropdowns. The value of these variables is never equal to one of the dropdown choices. I have to automate to avoid errors of choice by users. I can with php but I would like to try with the chronoform events.