簡體   English   中英

Idealforms:帶addfield的預選選項

[英]Idealforms: preselect option with addfield

我真的很想嘗試找出如何在使用addfield添加的下拉列表中預先選擇一個選項。 我可以這樣添加文本字段,我可以使用該字段數組中的value:'xyz'進行填充。 但選擇框無法識別。 誰能幫忙。 (而且,我使用的是Idealforms 2,而不是3)我的下拉代碼如下所示:

var newFields = [
    {
    name: 'accounttype',
    label: 'Account type',
    filters: 'exclude',
    data: { exclude: ['default'] },
    errors: { exclude: 'Please select account type' },
    type: 'select',
    list: [
        'Select account type::default',
        'Current/Cheque::1',
        'Savings::2',
        'Transmission::3'
    ],  
    value: 'Transmission::3',
    addAfter: 'pay-options'
},

我嘗試了值行中的所有可能選項,還嘗試稍后使用下面的jquery選擇它,以防其出現AJAX計時問題。 但還是很卡 請有人可以看一下:)

var my_accounttype = '3';    
    $('#accounttype option').each(function(){
        var $this = $(this); 
        if ($this.val() == my_accounttype ) {
            alert ($this.val() + " == " + my_accounttype ); 
            $this.prop('selected', true);
            return false; 
        }
    });

有人有想法么? V

弄清楚了! 有點任務,但是這里...您要做的就是從html select輸入轉換為Idealforms樣式列表后找到實際元素。 然后模擬點擊!

( document ).ready(function() {
        dateforuse = gup('salarydate3');
        if(dateforuse[0] == 0){ dateforuse = dateforuse[1]; } //in case date below 10 and leads with a zero
        $( ".salarydate3 li ul li" ).each(function( index ) {
            if( $( this ).text() == dateforuse){
                $( this ).click();
            }
        });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM