我有一个表单,当我提交我的变量值时,它将变为空。 知道什么可以吗?
我的代码:
$('#botaoSalvar').click(function () {
$('form').trigger('submit');
});
$('form').submit(function () {
if (defaults.tipoAcao == 2) {
var retorno = ($('form').serialize());
} else {
var retorno = nomeidRegistro + '=' + idRegistro + '&' + ($(this).serialize());
}
debugger
return retorno;
HTML:
<div id="alterarDados" aria-labelledby="ui-id-4" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" style="display: block;" aria-expanded="true" aria-hidden="false"><h3>Alterar Registro</h3>
<form id="formAlterar" action="/teste/index3" method="post">
<div id="corpoTabelaAlterar"><tr id="atributo2">
<td><label for="DescricaoBaseDados">DescricaoBaseDados:</label>
</td><td><input type=" name=" descricaobasedados"="" value="1">
</td></tr><tr id="atributo3"><td><label for="NomeBaseDados">NomeBaseDados:</label>
</td><td><input type=" name=" nomebasedados"="" value="1">
</td></tr><tr><td><input id="botaoVoltar" type="button" value="Voltar" name="voltar">
</td><td><input id="botaoSalvar" type="submit" value="Salvar" name="salvar">
</td></tr></div><table cellpadding="4" cellspacing="1" width="450" id="tabelaAlterar">
</table>
</form>
</div>
答案 0 :(得分:1)
您的代码中出现了一些错误:
</td><td><input type=" name=" descricaobasedados"="" value="1">
</td></tr><tr id="atributo3"><td><label for="NomeBaseDados">NomeBaseDados:</label>
</td><td><input type=" name=" nomebasedados"="" value="1">
您的type
属性未在上面设置。你在name
属性的语法中也有错误。它应该遵循以下格式:
<input type="text" name="descricaobasedados" value="1">
将type
替换为您正在使用的type
。
我不知道这是否是你的全部问题,但我确信这肯定是有帮助的。使用name
属性发布(提交)表单中的输入。如果未正确定义属性,您可能会收到null
个值。
希望这有帮助。