簡體   English   中英

表單提交后,輸入復選框無法正常工作

[英]Input checkbox doesn't work properly after the form is submit

我試過添加:

   <meta http-equiv="cache-control" content="max-age=0" />
   <meta http-equiv="cache-control" content="no-cache" />
   <meta http-equiv="expires" content="0" />
   <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
   <meta http-equiv="pragma" content="no-cache" />

並補充說:

  'autocomplete' => 'off'

並補充說:

  onload="document.getElementById('myform').reset()

在我的表單和 html 標簽上。

但是提交表單后復選框仍然無法正常工作。

我對復選框所做的是在選中時啟用/禁用某些輸入。

$(document).ready(function(e) {

    $('#checkSpend').change(function(){
        if ($(this).is(':checked')) 
            {
                $('li.opcititycheckSpend').fadeTo(500,1);
                $('input.group1').removeAttr('disabled');
            } 
        else if ($(this).not(':checked'))
            {
                $('li.opcititycheckSpend').fadeTo(500,0.5);
                $('input.group1').attr('disabled','disabled');
            }
    })  


    $('#checkRegister').change(function(){
        if ($(this).is(':checked')) 
            {
                $('li.opcititycheckRef').fadeTo(500,1);
                $('input.checkRegistered').removeAttr('disabled');
                $('#inputFrom').focus();
            } 
        else  
            {
                $('li.opcititycheckRef').fadeTo(500,0.5);
                $('input.checkRegistered').attr('disabled','disabled');
            }
    })  


    $('#checkTopup').change(function(){
        if ($(this).is(':checked')) 
            {
                $('li.opcititycheckTopup').fadeTo(500,1);
                $('input.checktoped').removeAttr('disabled');
            } 
        else if ($(this).not(':checked'))
            {
                $('li.opcititycheckTopup').fadeTo(500,0.5);
                $('input.checktoped').attr('disabled','disabled');
            }
    })
    cache: false
});

當我重新加載頁面時,它可以正常工作。

提交表單后如何使它們再次正常工作。 (因為表單提交后,會再次跳轉到有表單模板的頁面重新提交表單。)

編輯:

添加事件處理程序后,嘗試trigger()

$('#checkSpend, #checkRegister, #checkTopup').trigger('change'); //triggers given event on page load

刪除這一行:

 onload="document.getElementById('myform').reset()"

暫無
暫無

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

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