我已经研究了一个多星期才开始工作。我对jquery知之甚少,甚至在IT社区与我的一些朋友联系过,但到目前为止还没有人能够帮助我。我基本上都是自学成才,所以如果编码看起来很糟糕,我道歉。任何有关此事的帮助将不胜感激。
我在jquery手风琴中有一个重复的形式(如下所示)。我只是希望ajax提交正确的数据并保持当前单元格关闭,这样用户每次按下按钮时都不必重新打开它。
function dg1(dgr, v1, v2, v3) {
var MM_update = document.getElementById(v1);
var id = document.getElementById(v2);
var green_disable = document.getElementById(v3);
$.ajax({
type: "POST",
url: 'disable.php',
data: { MM_update: MM_update.value, id: id.value, green_disable: green_disable.value
},
dataType: "html",
success: function(html){ var foo = dgr.id; $('#' + foo).html(html);
document.getElementById('submitDisGreen').disabled = true; }
});
}
这是重复的形式。
<form name="disable" method="POST" action="">
<input type="submit" id="submitDisGreen" value="Disable" <?php if ($row_Recordset1['green_disable'] != NULL) echo "disabled=\"disabled\"";?> onClick="dg1('dgr<?php echo $row_Recordset1['id']; ?>', 'MM_update<?php echo $row_Recordset1['id']; ?>', 'id<?php echo $row_Recordset1['id']; ?>', 'green_disable<?php echo $row_Recordset1['id']; ?>'); return false;"/>
<input type="hidden" name="MM_update" id="MM_update<?php echo $row_Recordset1['id']; ?>" value="disableGreen" />
<input type="hidden" name="id" id="id<?php echo $row_Recordset1['id']; ?>" value="<?php echo $row_Recordset1['id']; ?>" />
<input type="hidden" name="green_disable" id="green_disable<?php echo $row_Recordset1['id']; ?>" value="<?php echo $row_Recordset2['first_name']; ?> <?php echo $row_Recordset2['last_name']; ?>" />
</form>
答案 0 :(得分:0)
所以这是成品。感觉很高兴终于有了这个并且正在工作。谢谢大家。
function dg1(dgr, v1, v2, v3, v4) {
var MM_update = document.getElementById(v1).value;
var id = document.getElementById(v2).value;
var green_disable = document.getElementById(v3).value;
$.ajax({
type: "POST",
url: 'disable.php',
data: { MM_update: MM_update, id: id, green_disable: green_disable },
dataType: "html",
success: function(html){ var foo = dgr; $('#' + foo).html(html); $('#' + v4).attr("disabled","disabled"); }
});
}