【问题标题】:Input form wont submit?输入表单不会提交?
【发布时间】:2014-03-03 19:11:53
【问题描述】:
protected function pro_show_sendRequestForm(){
    echo("<SECTION id='page_content-small'>");
    echo("<ARTICLE>");
    echo("<table width='100%' cellspacing='5'>");
    echo("<tr><td><form method='post' action='main.php'></td></tr>");
    echo("<tr><td colspan ='2' align='center'><B><H2>Send a event form.</H2></B></td></tr>");
    echo("<tr><td align='left'><B>Name event:</B></td>");
    echo("<td align='left'><input name='sEventTitle' type='text' size='30' maxlength='50' required></td></tr>");   
    echo("<tr><td align='left'><B>Name organisation:</B></td>");          
    echo("<td align='left'><B>New: </B><input name='sNewOrganisationName' type='text' size='30' maxlength='50'></td></tr>");
    echo("<tr><td>&nbsp;</td><td align='left'><B>Or choose: </B>");
    $this->pro_OrganisationDropdown('sExcistingOrganisationRecordNumber'); 
    echo("</td><tr>");
    echo("<tr><td align='left'><B>E-mail address:</B></td><td align='left'>"); 
    echo("<input name='sEmailadress' type='text' size='30' maxlength='50' required></td></tr>");
    echo("<input type='hidden' name='sSubmitForm' value='SendIntakeForm'>");
    echo("<tr><td colspan='3' align='center'><input type='submit' value=' Sending '></td></tr>");
    echo("</form></table></ARTICLE></SECTION>");
}

大家好,
今天我创建了这个表格,它工作得很好。直到我开始测试,然后我发现输入字段“sEventTitle”中的某个值是未处理表单的原因。我检查并重新检查,但例如“Apple”的值被排除在外,而“菠萝”的值则没有。
因此,为了找出原因,我将所有其他输入字段都这样注释掉:

protected function pro_show_sendRequestForm(){
    echo("<SECTION id='page_content-small'>");
    echo("<ARTICLE>");
    echo("<table width='100%' cellspacing='5'>");
    echo("<tr><td><form method='post' action='main.php'></td></tr>");
    echo("<tr><td colspan ='2' align='center'><B><H2>Send a event form.</H2></B></td></tr>");
    echo("<tr><td align='left'><B>Name event:</B></td>");
    echo("<td align='left'><input name='sEventTitle' type='text' size='30' maxlength='50' required></td></tr>");   
    //echo("<tr><td align='left'><B>Name organisation:</B></td>");          
    //echo("<td align='left'><B>New: </B><input name='sNewOrganisationName' type='text' size='30' maxlength='50'></td></tr>");
    //echo("<tr><td>&nbsp;</td><td align='left'><B>Or choose: </B>");
    //$this->pro_OrganisationDropdown('sExcistingOrganisationRecordNumber'); 
    //echo("</td><tr>");
    //echo("<tr><td align='left'><B>E-mail address:</B></td><td align='left'>"); 
    //echo("<input name='sEmailadress' type='text' size='30' maxlength='50' required></td></tr>");
    echo("<input type='hidden' name='sSubmitForm' value='SendIntakeForm'>");
    echo("<tr><td colspan='3' align='center'><input type='submit' value=' Sending '></td></tr>");
    echo("</form></table></ARTICLE></SECTION>");
}

现在整个表单不会自己提交。这不可能是真的。
基础在那里:form 和 /form。一个输入名称 ='foo' type='text' 和一个提交按钮。为什么在较大的表格工作时不提交此表格?我的错误是什么?有什么我看不到的吗?任何帮助都会得到帮助。

main.php 中查看表单是否提交的第一行是:

$oMainPage = new main();
echo($_POST['sEventTitle']);
echo($_POST['sSubmitForm']);

浏览器生成的代码:

 <SECTION id='page_content-small'><ARTICLE><form method='post' action='main.php'>
 <table width='100%' cellspacing='5'><tr><td colspan ='2' align='center'><B>  
 <H2>Een aanmeldformulier versturen.</H2></B></td></tr><tr><td align='left'>  
 <B>Naam evenement:</B></td><td align='left'>  
 <input name='sEventTitle' type='text' size='30' maxlength='50' required></td></tr>  
 <input type='hidden' name='sSubmitForm' value='SendIntakeForm'><tr>  
 <td colspan='3' align='center'><input type='submit' value=' Versturen '></td></tr>  
 </table></form></ARTICLE></SECTION>

【问题讨论】:

  • 请不要对每一行都使用 echo。将您的 php 和模板 (html) 分开。
  • @hardy。我知道,但这是错误模式下的代码,所以我可以找到错误所在。
  • 我的代码没有问题。 Test it here
  • @cyper。你说得对,代码是可靠的,这就是为什么它如此奇怪。它应该工作,但它没有。而且我找不到问题。

标签: php forms submit


【解决方案1】:

&lt;td&gt; 中取出表格,将&lt;form&gt; 包裹在&lt;table&gt; 周围

【讨论】:

  • 好眼光 T McKeown,我在 jdkos 帖子中错过了这一点。
  • 我按照您的建议做了,并将表格包裹在桌子周围。但仍然没有快乐。
  • 粘贴您的 html,从浏览器执行“查看源代码”。粘贴正在生成的内容。
  • 我粘贴了代码,但我看不出有什么问题。你呢?
  • 什么是&lt;Section&gt;&lt;Article&gt;??
猜你喜欢
  • 2011-04-02
  • 1970-01-01
  • 2012-05-05
  • 2016-03-14
  • 2014-01-24
  • 2016-12-04
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
相关资源
最近更新 更多