0

I am using the Freeform 4.0.12 along with ExpressionEngine v2.6.1 for forms in one of my projects and I have a situation where I need to display drop down values dynamically - based on what value was chosen in the previous dropdown.

Similar to a country/province dropdown - Eg. If I choose USA - then my province dropdown is filled with places from the USA, but if I choose India, then the provice dropdwon is filled with places in India.

Any idea how I can incorporate something like this?

Also, i am having an issue with the validation of the select fields. I am supposed to make them required. I tried using the inline errors and making the fields required. for example {freeform:field:country} - when I put this in, if I don't choose any option, by default the first value is chosen, if I manually enter all the values, then the validation works in the sense that the form is not submitted, but it doesnt display the field required error.

I could really use some help in there areas.

2
  • Hey Sucharitha - first, please make each question a single question, as people may have an answer to one and not the other in this case. What have you tried re: inline validation in Freeform? Please post your code. Jul 22 '13 at 13:02
  • Ooo! I am so sorry, will remember to post separately from next time. I managed to solve both the issues this morning - the validation problem was that I forgot to add the {if freeform:error:my_field} <span class="error"> {freeform:error:my_field} </span>{/if} block for my select boxes and the other issue was solved using php/jquery and ajax as I posted below. Thanks so much :D
    – Sucharitha
    Jul 23 '13 at 3:10
1

Ok I managed to solve the dynamic dropdown values using some php/jquery and ajax, but I still have issues with the validation of the dropdown values. Can someone help me on that one?

1

I think, you are using "FreeForm Pro" and having "Select" field type for the country. And you are listing the countries within "Field Options" of field settings.

You should select "Value/Label List" from "List type" and for the first option put label like "-- Select Country --" with empty value. Now your country validation would work fine as the first/default country option will be submitted empty.

Share your further findings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.