我用jquery的一个函数动态增加input输入框,但是提交的时候好像php不认????form里面已经有两个选项,增加input输入框后,提交之后choice数据还是2(用下面红字的地方显示). 为什么呢???5555~~~快哭啦~~ 各位老师帮忙帮忙~~~
代码如下:
<?php if ($sendadd)
{
$db=initdb(); $data=$_POST["choice"]; }?><html>
<head>
<script type="text/javascript" src="../../include/jquery/tablesorter.pager/jquery-latest.js"></script>
<script >
// add method
$(document).ready(function(){ $("#but").click(function(){ //添加选项
var $table=$("#tab_choice tr");
var len=$table.length;
$("#tab_choice").append("<tr class=\"firstalt\" nowrap name=\"choice[]\" id="+(len)+"><td width=\"30%\" style=\"font-size:16px;\">选项"+(len)+":</td><td align='center'><input maxLength=\"100\" size=\"60\" name=\"title\" value=\"\"></td></tr>");
}) $("#but_del").click(function(){ //删除选项
$table=$("#tab_choice tr");
$("tr[id='"+($table.length-1)+"']").remove();
}) })
</script>
</head>
<body align="center">
<br/>
<? echo count($data); ?>
<form name="article" method="post" encType="multipart/form-data" >
<table class="tableoutline" cellSpacing="1" cellPadding="4" width="90%" align="center" border="0" id="tab_choice">
<tr id="cat">
<td class="tbhead" colSpan="3"><b>选项</b></td>
</tr>
<tr class="firstalt" nowrap>
<td width="30%" style="font-size:16px;">选项1:</td>
<td align='center'><input maxLength="100" size="60" name="choice[]" value=""> </td>
</tr>
<tr class="firstalt" nowrap>
<td width="30%" style="font-size:16px;">选项2:</td>
<td align='center'><input maxLength="100" size="60" name="choice[]" value=""> </td>
</tr>
</table> <table class="tableoutline" cellSpacing="1" cellPadding="4" width="90%" align="center" border="0" >
<tr class="tbhead">
<td align="right" colSpan="2">
<input class="bginput" type="button" id="but" value="添加选项"/>
<input class="bginput" type="button" id="but_del" value="删除选项"/>
<input class="bginput" accessKey="y" type="submit" value=" 提交 " name="sendadd">
</td>
</tr>
</table>
</form>
</body>
</html>
代码如下:
<?php if ($sendadd)
{
$db=initdb(); $data=$_POST["choice"]; }?><html>
<head>
<script type="text/javascript" src="../../include/jquery/tablesorter.pager/jquery-latest.js"></script>
<script >
// add method
$(document).ready(function(){ $("#but").click(function(){ //添加选项
var $table=$("#tab_choice tr");
var len=$table.length;
$("#tab_choice").append("<tr class=\"firstalt\" nowrap name=\"choice[]\" id="+(len)+"><td width=\"30%\" style=\"font-size:16px;\">选项"+(len)+":</td><td align='center'><input maxLength=\"100\" size=\"60\" name=\"title\" value=\"\"></td></tr>");
}) $("#but_del").click(function(){ //删除选项
$table=$("#tab_choice tr");
$("tr[id='"+($table.length-1)+"']").remove();
}) })
</script>
</head>
<body align="center">
<br/>
<? echo count($data); ?>
<form name="article" method="post" encType="multipart/form-data" >
<table class="tableoutline" cellSpacing="1" cellPadding="4" width="90%" align="center" border="0" id="tab_choice">
<tr id="cat">
<td class="tbhead" colSpan="3"><b>选项</b></td>
</tr>
<tr class="firstalt" nowrap>
<td width="30%" style="font-size:16px;">选项1:</td>
<td align='center'><input maxLength="100" size="60" name="choice[]" value=""> </td>
</tr>
<tr class="firstalt" nowrap>
<td width="30%" style="font-size:16px;">选项2:</td>
<td align='center'><input maxLength="100" size="60" name="choice[]" value=""> </td>
</tr>
</table> <table class="tableoutline" cellSpacing="1" cellPadding="4" width="90%" align="center" border="0" >
<tr class="tbhead">
<td align="right" colSpan="2">
<input class="bginput" type="button" id="but" value="添加选项"/>
<input class="bginput" type="button" id="but_del" value="删除选项"/>
<input class="bginput" accessKey="y" type="submit" value=" 提交 " name="sendadd">
</td>
</tr>
</table>
</form>
</body>
</html>
解决方案 »
- 在opera浏览器中,如何在iframe页面调用父页面的JS函数。iframe的src页面是跨域页面
- var fAppVersion=parseFloat(navigator.appVersion);
- js 相册效果
- 高手来帮我改改这个图片展示效果
- document.write输出相同的内容 只显示一个
- 这个脚本怎么实现;
- 怎样制作才能在弹出的小窗口网页上出现滚动条?100!
- 百思不得其解请高手帮忙(100分):为什么改变图象域的图象后提交,按IE浏览器的后退按纽,图象域的图象变成未改变时的样子(应该是改变后的样
- dxm!Sos,如何用JS实现类似WWW.GO2MAP.COM.CN上缩放滑动条?
- JavaScript 显示波形图功能
- 这个js跳转是怎么实现的
- 我不甘心啊!为什么JavaScript更新年月日可以更新年,但是不能更新月呢?帮我看下,我不甘心就这样放弃啊~~~~~~~~~~~~~~~~~~
<input maxLength=\"100\" size=\"60\" name=\"title\" value=\"\">