多表格提交

时间:2011-10-27 05:51:05

标签: javascript

function saveConfig(val)
{
    if(val == 1){       
        document.f1.submit();       
        document.f4.submit();       
    }
    else if(val == 2){              
        document.f2.submit();       
    }
    else if(val == 3){      
        document.f3.submit();       
    }
    document.f0.submit();
}

嗨以上代码在IE6,IE7,IE8,FF3.0.19,FF3.5.19和FF3.6.20中运行良好。但是它不适用于Firefox版本> 4.请帮助我理解上述代码的错误。

2 个答案:

答案 0 :(得分:0)

可以尝试使用 var form1 = document.getElementsByName('f1'); form1.submit();

答案 1 :(得分:0)

function f0Submit() {
  document.f0.submit();
}

function f4Submit() {
  var dataString = $('f4').serialize();

    new Ajax.Request('url', {
      method: 'post',
      parameters: dataString,
      onSuccess: function(data) {
                   f0Submit();
                 }
   });
}

function saveConfig(val) {
  if(val == 1) {
    var dataString = $('f1').serialize();

    new Ajax.Request('url', {
      method: 'post',
      parameters: dataString,
      onSuccess: function(data) {
                   f4Submit();
                 }
    });
  }
  else if(val == 2){              
    var dataString = $('f2').serialize();

    new Ajax.Request('url', {
      method: 'post',
      parameters: dataString,
      onSuccess: function(data) {
                   f0Submit();
                 }
    });       
  }
  else if(val == 3){      
    var dataString = $('f3').serialize();

    new Ajax.Request('url', {
      method: 'post',
      parameters: dataString,
      onSuccess: function(data) {
                   f0Submit();
                 }
    });       
  }     
}