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 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建