Forums › Forums › Search & Filter Pro › Hide a field when i choose an option
Tagged: filter select, hide select
- This topic has 3 replies, 2 voices, and was last updated 8 years, 3 months ago by Trevor.
-
Anonymous(Private) July 20, 2016 at 6:41 am #51682
Hello, I have a question , I tried to hide a field by choosing an option from a select field, but only do it once, and not do it again when I select another, I have tried with jquery “switch and on change”.
I have a select with various states of Mexico , when I choose a state , a select field must appear with other cities of that state, but only does the first time i choose a state.
Example
$(".sf-field-post-meta-estado .sf-input-select").change(function(){ var id = $(this).find("option:selected").val(); switch (id){ case "Nuevo León": $('.sf-field-post-meta-coahuila').hide() $('.sf-field-post-meta-nuevoleon').show() break; case "Coahuila": $('.sf-field-post-meta-nuevoleon').hide() $('.sf-field-post-meta-coahuila').show() break; } });
.sf-field-post-meta-estado .sf-input-select
is the select field of the states of mexico with options like “Nuevo León, Coahuila”.sf-field-post-meta-coahuila, .sf-field-post-meta-coahuila
These are the city containers of their respective statesHow could I accomplish that?, I think some script is interfering, idk.
cheers!
Anonymous(Private) July 21, 2016 at 1:51 am #51761its a post, is a filter for a real estate, in the same form i have
1 – a searchfield
2 – a sort field
4 – a meta field (select) with two options (‘rent’, ‘sale’)
5 – a meta field (select) with all categories (like 9)
6 – a meta field (select) with the states of mexico (2 options at the moment: nuevo león and coahuila)
7 – a meta field (checkbox) with the cities of nuevo león state (like 31 options)
8 – a meta field (checkbox) with the cities of coahuila state (like 20 options)
9 – a meta field (number) with the range of prices
10 – a meta field (number) with the range of areaI would like to accomplish, that when someone select “nuevo leon” only the meta field of the cities of “Nuevo Leon” show, and the meta field of Coahuila hide, and viceversa (its like a “next step” state > city), i’m trying to do this with jquery “if and else or switch case”, but only do that the first time i select one of these.
thanks for the reply!
-
AuthorPosts