寫form提交應該注意的

來源:互聯網
上載者:User

簡介:這是寫form提交應該注意的的詳細頁面,介紹了和php,PHP 寫form提交應該注意的有關的知識、技巧、經驗,和一些php源碼等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=350527' scrolling='no'>
前兩天改bug,發現一個表單提交提交的問題,先上代碼:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Test</title> <script type="text/javascript" src="http://www.z7zba.com/js/jquery-1.4.4.min.js"></script></head> <style type="text/css"> </style> <body> <?print_r($_POST); echo "\r\n";?><table border="0" cellpadding="0" cellspacing="0"><form id="theFrom" name="theForm" action="demo.php" method="post"><tr>    <td id="tdName"><input type="text" id="name" name="name" /></td>    </tr><tr>    <td><a href="javascript:searchName();">尋找姓名</a>&nbsp;<a href="javascript:doSubmit();">提交</a></td>    </tr>    </form></table><script type="text/javascript"> function searchName(){//可以是ajax返回內容var data = '<select id="nameId" name="nameId"><option value="1">Cheech</option><option value="2">Mark</option></select>';$("#tdName").html(data);}function doSubmit(){$("#theFrom").submit();}</script> </body> </html>

當其中的 <input type="text" id="name" name="name" /> 被換成 <select id="nameId" name="nameId"><option value="1">Cheech</option><option value="2">Mark</option></select> 進行提交。

$_POST['nameId']在使用 ie 瀏覽器提交,程式可正常接收到參數 ,而使用Chrome,FireFox提交,程式不能提收到參數

問題出在form的位置套錯了。將form套在table外問題就解決了。如下:(其他不變)

<form id="theFrom" name="theForm" action="demo.php" method="post"><table border="0" cellpadding="0" cellspacing="0"><tr>    <td id="tdName"><input type="text" id="name" name="name" /></td>    </tr><tr>    <td><a href="javascript:searchName();">尋找姓名</a>&nbsp;<a href="javascript:doSubmit();">提交</a></td>    </tr></table></form>

愛J2EE關注Java邁克爾傑克遜視頻站JSON線上工具

http://biancheng.dnbcw.info/php/350527.html pageNo:3

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.