dousou2897 2013-07-16 09:12
浏览 36
已采纳

PHP生成的表单不提交AJAX

I have a select with ROWID in the value and the name in the value,

<select name="opcoes"  onchange="showInfo(this.value)">
<option value=''>Select</option>
<option value=6>A</option>
<option value=2>F</option>
<option value=5>L</option>
<option value=1>M</option>
</select>

when you select one i have this ajax code to create a form with php,

    function showInfo(str)
{


if (str=="")
  {

  document.getElementById("fields").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("fields").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","php/vendors/getRow.php?id="+str,true);
xmlhttp.send();
}

Next if the selected value isnt "" it goes to the php,

...conection to the database...

echo "<form action='/php/vendors/edit.php' onSubmit=\"return confirm('Deseja editar?')\" method='post' >"; 
echo "<td><input type='text' name='editname'   value='".utf8_encode($linha[vendor_name])."'    ></td>";
echo "<td><input type='text' name='editemail'    value='".utf8_encode($linha[vendor_email])."'    ></td>";
echo "<td><input type='text' name='editwebsite'    value='".utf8_encode($linha[vendor_website])."'  ></td>";
echo "<td><input type='text' name='editphone'    value='".utf8_encode($linha[vendor_phone])."'    ></td>";
echo "<td><input type='text' name='editfax'     value='".utf8_encode($linha[vendor_fax])."'     ></td>";
echo "<td><input type='text' name='editadress'    value='".utf8_encode($linha[vendor_adress])."'   ></td>";
echo "<td><input type='text' name='editincharge'   value='".utf8_encode($linha[vendor_incharge])."'  ></td>";
echo "<td class='btn'><input class='edit' type='submit' value=''></td>";
echo "</form>";

It displays every information correctly the ONLY problem is that it does not submit when i click the input submit button... any ideas why?

  • 写回答

2条回答 默认 最新

  • doudeng3008 2013-07-16 09:31
    关注

    You are generating invalid HTML.

    A form can contain an entire table. A table cell can contain an entire row. A form cannot exist inside a table but around a set of cells in that table.

    Your browser is error recovering by moving the form to after the table but leaving the form controls behind.

    This means that the submit button isn't inside a form so it can't submit a form.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里