【发布时间】:2012-03-01 22:44:45
【问题描述】:
我正在尝试在更改 HTML 中的文本字段时提交表单。目前,我的代码如下所示:
echo("<form name=\"editAgendaItem" . $this->Id . "\" id=\"editAgendaItem" . $this->Id . "\" method=\"post\" action=\"./?module=meetings&preload=edit&function=editAgendaItem&agendaitem=" . $this->Id . "\">\n");
echo("<table width=\"100%\" border=0>\n");
echo("<tr><td width=\"20px\">" . $this->Index . "</td><td><input type=\"text\" value=\"" . $this->Title . "\" name=\"agendaItemTitle" . $this->Id . "\" onChange=\"javascript:document.forms['editAgendaItem" . $this->Id . "'].submit();\" />");
echo("</td>\n");
...
计算结果为
<form name="editAgendaItem19" id="editAgendaItem19" method="post" action="./?module=meetings&preload=edit&function=editAgendaItem&agendaitem=19">
<table width="100%" border=0>
<tr><td width="20px">1</td><td><input type="text" value="" name="agendaItemTitle19" onChange="javascript:document.forms['editAgendaItem19'].submit()" /></td>
...
但更重要的是
<form name="editAgendaItem19" id="editAgendaItem19" method="post" action="...">
<input type="text" value="" name="agendaItemTitle19" onChange="javascript:document.forms['editAgendaItem19'].submit()" />
...
- 最终由标签终止。我的问题是,在修改字段并放下焦点后,表单没有提交。
提前感谢您的帮助。
编辑:
我也尝试在 onChange 事件中使用此方法而不是内联代码:
<script type="text/javascript">
function submitForm(FormName)
{
document.forms[FormName].submit();
}
</script>
编辑:
接受了使用以下代码的建议:
<script>
$(document).ready(function(){
$('#agendaItemTitle24').live('blur',function()
$('#editAgendaItem24').submit();
});
});
</script>
在我的脑海里,并且
<form name="editAgendaItem24" id="editAgendaItem24" method="post" action="...">
<input type="text" value="" name="agendaItemTitle24" id="agendaItemTitle24" />
</form>
在我的内容中。还是没有骰子。
【问题讨论】:
-
您的 javascript 控制台中是否收到任何错误或警告?如果是这样,你能把它们贴在这里吗?
-
不,我是 octern。这就是为什么“- octern”出现在我的 cmets 末尾的原因。
标签: php javascript html forms http-post