2 개의 드롭 다운 상자에서 작동하는 jquery 비트를 연마 중입니다. 기본적으로 첫 번째 드롭 다운이 변경되면 적용 가능한 선택 사항 만 표시되도록 두 번째 드롭 다운을 필터링합니다. 첫 번째 드롭 다운에서 첫 번째 선택 사항 (값 : "none |")을 선택하면 두 번째 선택 항목이 표시되지 않습니다.관련 드롭 다운 메뉴 문제
대단히 효과적입니다. 문제는 다음과 같습니다. 첫 번째 드롭 다운에서 첫 번째 선택 사항을 선택하면 두 번째 드롭 다운이 지워집니다. 그러나 첫 번째 드롭 다운에서 다른 옵션을 선택하면 두 번째 옵션은 비어있을 때 비어 있습니다.
내가 알아낼 수 있도록 도와 주시면 감사하겠습니다. 여기에서 드롭 다운 상자를 찾을 수 있습니다 : http://goinspire.com/jwrp-hotel-registration/.
추신 : 나는 차이가 있지만 (생각하지 않는다), WordPress 사이트이며 양식은 GravityForms에 의해 생성됩니다.
PS : 내가 제대로 이해 한 경우
tripFilter = function() {
var tripClass = '.hotel-trip select',
hotelClass = '.hotel-name select',
unusedClass = '.unused-options select';
jQuery(tripClass).change(function(){
//testFunc();
var tripSelect = jQuery(tripClass),
trip = tripSelect.val(),
hotelSelect = tripSelect.parents('form').find(hotelClass);
if (trip === "none|"){
jQuery(hotelClass+" > option").each(function() {
jQuery(this).clone().appendTo(unusedClass);
jQuery(this).remove();
});
} else {
tripnum = trip.match(/JWRP (\d*)/)[1];
//var hotelChoices = [];
jQuery(unusedClass+" > option").each(function() {
jQuery(this).clone().appendTo(hotelClass);
jQuery(this).remove();
});
jQuery(hotelClass+" > option").each(function() {
hotelMatch = jQuery(this).val().match(/(\d*) /);
//console.log(hotelMatch);
if (hotelMatch === null || hotelMatch[1] != tripnum){
jQuery(this).clone().appendTo(unusedClass);
jQuery(this).remove();
//console.log("not a match!");
};
});
}
});
};
jQuery(document).ready(function() {
tripFilter();
});
jQuery(document).bind('gform_post_render', function(event, form_id){
if(form_id == 38) {
tripFilter();
}
});
사용은 그래서 미래의 독자들이 혜택을 누릴 수 있습니다 여기에 코드의 관련 부분을 붙여 넣어야합니다 - 사이트는 추락 또는 다른 문제, URL 변경의 경우. –
브라우저의 콘솔을 확인하고 먼저 오류를 수정하십시오. – Alex
저는이 2 가지를 작업하고 있습니다. 그러나 오류 – user3515