Hi everybody,
i have created a .js for show - hide the options of a select list. The problem that i have is that .hide() and .show() works only for Firefox.
The .js i have is the following
jQuery("#customfield_12300").change(function() {
if (jQuery("#customfield_12300").val() == '11400') {
//Unselect all values on change event
jQuery("#customfield_12302").val([]);
//Hide Pending Reasons that do not match the type of account
jQuery("#customfield_12302").children("option[value='11402']").hide();
jQuery("#customfield_12302").children("option[value='11404']").hide();
jQuery("#customfield_12302").children("option[value='11505']").hide();
jQuery("#customfield_12302").children("option[value='11506']").hide();
jQuery("#customfield_12302").children("option[value='11507']").hide();
jQuery("#customfield_12302").children("option[value='11508']").hide();
jQuery("#customfield_12302").children("option[value='11509']").hide();
//Show pending reasons that match the type of account
jQuery("#customfield_12302").children("option[value='11510']").show();
jQuery("#customfield_12302").children("option[value='11511']").show();
jQuery("#customfield_12302").children("option[value='11512']").show();
jQuery("#customfield_12302").children("option[value='11513']").show();
jQuery("#customfield_12302").children("option[value='11514']").show();
} else if (jQuery("#customfield_12300").val() == '11401'){
jQuery("#customfield_12302").val([]);
//Hide Pending Reasons that do not match the type of account
jQuery("#customfield_12302").children("option[value='11510']").hide();
jQuery("#customfield_12302").children("option[value='11511']").hide();
jQuery("#customfield_12302").children("option[value='11512']").hide();
jQuery("#customfield_12302").children("option[value='11513']").hide();
jQuery("#customfield_12302").children("option[value='11514']").hide();
//Show pending reasons that match the type of account
jQuery("#customfield_12302").children("option[value='11402']").show();
jQuery("#customfield_12302").children("option[value='11404']").show();
jQuery("#customfield_12302").children("option[value='11505']").show();
jQuery("#customfield_12302").children("option[value='11506']").show();
jQuery("#customfield_12302").children("option[value='11507']").show();
jQuery("#customfield_12302").children("option[value='11508']").show();
jQuery("#customfield_12302").children("option[value='11509']").show();
}
});
Here is the html code for the list with the options i want to control
<div class="field-group">
<label for="customfield_12302">Pending Reasons<span class="aui-icon icon-required">Required</span></label>
<select class="select" id="customfield_12302" multiple="multiple" name="customfield_12302" size="5">
<option value="11402" style="display: none; ">
Option 1
</option>
<option value="11404" style="display: none; ">
Option 2
</option>
<option value="11403">
Option 3
</option>
<option value="11405">
Option 4
</option>
<option value="11500">
Option 5
</option>
<option value="11501">
Option 6
</option>
<option value="11502">
Option 7
</option>
<option value="11503">
Option 8
</option>
<option value="11504">
Option 9
</option>
<option value="11511">
Option 10
</option>
<option value="11510">
Option 11
</option>
<option value="11512">
Option 12
</option>
<option value="11505" style="display: none; ">
Option 13
</option>
<option value="11506" style="display: none; ">
Option 14
</option>
<option value="11507" style="display: none; ">
Option 15
</option>
<option value="11508" style="display: none; ">
Option 16
</option>
<option value="11509" style="display: none; ">
Option 17
</option>
<option value="11513">
Option 19
</option>
<option value="11514">
Option 20
</option>
</select>
<div class="description">Ctrl+Click to choose multiple values</div>
</div>
From things i have seen .show() and .hide() are not available for Chrome.
A workaround was to use .detach() and .append() but that breaks the order of options in select list.
Any ideas how to make it work for the majority of browsers?
Thanks in advance,
Kostas