I have a drop down that I check with jquery and if a certain value is selected then an input box is revealed. I need to compare the selected value with an array and if the selection matches one of the values in the array then the value must be added to my hidden field’s tag. Advice would be very much appreciated since my jquery knowledge is next to none
My current code:
(I will query my database to get all the child values of trekkers and that will be my array)
<script type="text/Javascript">
jQuery(function ($){
$(document).ready(function () {
$(".kw").hide();
});
$(function(){
$('.postform').change(function() {
var selectData = $(this).attr("data-select");
var selectValue = $(this).val();
$('.kw').hide();
if($("fieldset[data-select='" + selectData + selectValue +"']").css("display") == "none"){
$("fieldset[data-select^='" + selectData + "']").hide();
$("fieldset[data-select='" + selectData + selectValue +"']").show();
}
});
});
});
</script>
<form role="search" method="get" id="equipfilter" action="">
<fieldset>
<select name="exc_equipment_cat" id="exc_equipment_cat" class="postform" data-select="select1">
<option class="level-0" value="allerlei">Allerlei (10)</option>
<option class="level-0" value="implemente">Implemente (97)</option>
<option class="level-1" value="balers-toebehore"> Balers & Toebehore (4)</option>
<option class="level-1" value="disse"> Disse (4)</option>
<option class="level-1" value="hammermeule"> Hammermeule (4)</option>
<option class="level-1" value="ploee"> Ploeë (11)</option>
<option class="level-1" value="ripper"> Ripper (8)</option>
<option class="level-0" value="trekkers">Trekkers (43)</option>
<option class="level-1" value="case"> Case (4)</option>
<option class="level-1" value="fiat"> Fiat (5)</option>
<option class="level-1" value="ford"> Ford (1)</option>
<option class="level-1" value="john-deere"> John Deere (13)</option>
<option class="level-1" value="landini"> Landini (5)</option>
<option class="level-1" value="massey-ferguson"> Massey Ferguson (3)</option>
<option class="level-1" value="mccormick"> McCormick (4)</option>
<option class="level-1" value="new-holland"> New Holland (8)</option>
</select>
</fieldset>
<fieldset class="kw" data-select="select1 WHERE VALUE SHOULD BE ADDED" style="display: none;">
<legend>Kw Range:</legend>
<input type="text" name="kw_min" placeholder="min" value=""><br>
<input type="text" name="kw_max" placeholder="max" value="">
</fieldset>
<fieldset>
<legend>Price Range:</legend>
<input type="text" name="pr_min" placeholder="from" value=""><br>
<input type="text" name="pr_max" placeholder="to" value="">
</fieldset>
<input type="submit" id="filtersubmit" value="Search">
</form>
This is in response to this question
i hope this helps you
answer to your first question: