PHP生成的表单未提交AJAX [英] PHP generated form does not submit AJAX

查看:97
本文介绍了PHP生成的表单未提交AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择,值中有ROWID,值中有名称,

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>

当您选择一个时,我拥有此ajax代码以用php创建表单,

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();
}

接下来,如果所选值不是",则转到php,

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?

推荐答案

您正在生成无效的HTML.

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.

这篇关于PHP生成的表单未提交AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆