2017-05-10 41 views
0

我有一個條件下,我有一個下拉選項,其上有5個選項。 任何選項的點擊,「fancybox」模式窗口打開。但我不想 想打開fancybox時點擊「選項1」。根據 條件,我不能放置「選項1的值屬性」。其他全部 有價值屬性。不要打開fancybox點擊一個特定的下拉選項

function openFB(focusAeraData, idData) { 
    var userIdData = $("#userIdData").val(); 
    var focusAreaSelectBoxValue01 = $("#focusAera1").val(); 
    var focusAreaSelectBoxValue02 = $("#focusAeraFirst").val(); 
    var focusAreaSelectBoxValue03 = $("#focusAeraSecond").val(); 

    if ((focusAreaSelectBoxValue01 == focusAreaSelectBoxValue02 || focusAreaSelectBoxValue02 == focusAreaSelectBoxValue03) 
      && idData == 2) { 
     $("#focusAeraError2").html('Please Select different Focus'); 
     $("#focusAeraFirst").val(''); 
     $("#focusAreaContent2").html(''); 
     $('#foucusAreaLaunchURL2').html(""); 
     $('#focusAeraFirst>option:eq(0)').prop('selected', true); 
     $("#focusAeraError3").html(''); 
     $("#focusAeraError1").html(''); 
    } else if ((focusAreaSelectBoxValue01 == focusAreaSelectBoxValue03 || focusAreaSelectBoxValue02 == focusAreaSelectBoxValue03) 
      && idData == 3) { 
     $("#focusAeraError3").html('Please Select different Focus'); 
     $("#focusAeraSecond").val(''); 
     $('#focusAeraSecond>option:eq(0)').prop('selected', true); 
     $("#focusAeraError2").html(''); 
     $('#foucusAreaLaunchURL3').html(""); 
     $("#focusAreaContent3").html(''); 
     $("#focusAeraError1").html(''); 
    } 

    else { 

     $("#focusAeraError" + idData).html(''); 
     getValueDataRemove(idData); 
     var OpenPOPUPURL = '../../pop_up/get_popup_scorecard?idData=' 
       + idData + '&focusAeraData=' + focusAeraData + '&userId=' 
       + userIdData; 
     $.fancybox({ 
      autoSize : true, 
      'maxWidth' : '35%', 
      'minWidth' : '35%', 
      'width' : '680', 
      modal   : false, 
      fitToView : true, 
      'padding-bottom' : '5px', 
      arrows : false, 
      openEffect : 'fade', 
      openSpeed : 'slow', 
      closeEffect : 'fade', 
      closeSpeed : 'slow', 
      closeBtn : false, 
      href : OpenPOPUPURL, //Your form must have an action. 
      type : 'ajax', 
      'helpers' : { 
       'overlay' : { 
        'closeClick': false, 
       } 
      }, 
      ajax : { 
       type : "GET", 
       cache : false, 
       data : $(this).serializeArray(), 
      }, 
      scrolling : 'no', 

      iframe : { 
       scrolling : 'auto', 
       preload : true 
      } 

     }) 

    } 
} 
+0

你能發佈生成的html嗎? – Sagar

回答

1

如果can't place "Value attribute for Option 1",那麼就檢查是否有值,跳過如果沒有。例如:

if (!focusAreaSelectBoxValue01 || !focusAreaSelectBoxValue02 || !focusAreaSelectBoxValue03) { 
    return; 
} 
+0

我已經嘗試過,如果條件以上,但我的fancybox根本沒有開放。 – wikijames

0

,如果你想調理的fancybox當你切換到選項1,除了開,那麼你可以做這樣的事情

做了一個簡單的例子,因爲你的HTML就不貼了。但你明白了。你只需要插入如果條件

內的fancybox看到下面片斷

$("select").on("change", function() { 
 
    if (!this.selectedIndex == 0) { 
 
    $(this).css({ 
 
     'color': 'red' 
 
    }) 
 
    } else { 
 
    $(this).css({ 
 
     'color': 'black' 
 
    }) 
 
    } 
 
})
<select> 
 
<option>Option1</option> 
 
<option>Option2</option> 
 
<option>Option3</option> 
 
<option>Option4</option> 
 
<option>Option5</option> 
 
</select>

+0

同意你的功能,但整個問題是它不是一種顏色。這是一個fancybox和代碼已經由其他人在選擇fancybox打開.. – wikijames

+0

好。我讓你只是一個例子。而不是'$(this).css({....'你可以禁用/啓用fancybox裏面的IF條件 –

+0

我已經嘗試過,但然後它爲所有選項做 – wikijames

相關問題