I have a form with a select dropdown field where the ID is field_cityname-0 and the meta name is item_meta[21][0][24]. The ID and the name were obtained using web inspect. Then the JS reference should be
document.getElementById("field_cityname-0");
But when I check the formidable form documentation, I saw the field reference, as below.
select[name='item_meta[994]']
Is it a must to use the above reference or can I use document.getElementById. I'm still new to JS so all the helpful answers are welcome.
Please login or Register to submit your answer
If you go to https://formidableforms.com/knowledgebase/javascript-examples/#kb-referencing-field-types and then scroll down to the next section on "Conditionally hide/show a field", that will give you an example of how to use the select item. That is the ideal way to reference select fields.
Thanks for your answer @Bobby Clapp . What I'm doing is getting the entries from a dropdown in Formidable form and using those entries I want to create markers on google maps. So can I get the values from form fields, by using another external script file?
Wrap this in script tags:
jQuery('select[name='item_meta[994]']').on('change', function() {
alert( this.value );
});
Change the 994 to your field ID. This is a short simple example to get the value of the field when changed.