conditional select field on CC

How to create a conditional select field in ChronoForms.

Overview

The issue was that a select field's options needed to change dynamically based on the value of another field, but initial attempts using PHP failed due to incorrect quotation marks.
Use a PHP code area to return the correct HTML select element based on the value of the controlling field, ensuring proper syntax for the quotation marks.

Answered
teldrive teldrive 03 Sep, 2014
Hi everyone
i need one select field1 on CC, that can change of options when field2=1 or field2=2

when field2=1
1=option1
2=option2
3=option3

and when field2=2
4=option4
5=option5
6=option6

I have got one select field using "fields" area

model.field1:<select name="model[{model.id}][field1]"  class="form-control A"  ><option value="{model.field1}">{model.field1}</option><option value="0">None</option><option value="1">opt one</option>.........</select>


but i don't know if posible change select options based on field2, I tried with php code without sucess
please let me know if possible
teldrive teldrive 05 Sep, 2014
Answer
1 Likes
I solved it, it was an issue with quotation marks
this code works on php area
paper.sesion:return ($row['paper']['poster']=="1") ? "<select name='paper[{paper.id}][sesion]'  class='form-control A'><option value='{paper.sesion}'>{paper.sesion}</option><option value='1'>oral</option></select>" :"<select name='paper[{paper.id}][sesion]'  class='form-control A'><option value='{paper.sesion}'>{paper.sesion}</option><option value='1'>poster</option></select>";
This topic is locked and no more replies can be posted.