日期:2014-05-16  浏览次数:20347 次

html input框 只能获得第一段的值
  </tr>
  {dede:datalist}
   <tr>
    <td id="com_title" height="25" align="center" bgcolor="#FFFFFF">{dede:field.title/}</td>
    <td id="com_price" height="25" align="center" bgcolor="#FFFFFF">{dede:field.price/}</td>
    <td id="com_buynum" height="25" align="center" bgcolor="#FFFFFF">{dede:field.buynum/}</td>
<td height="25" align="center" bgcolor="#FFFFFF"><input type="text" id="customtax" name="customtax" value="{dede:field.customtax/}"></td>
  </tr>
  {/dede:datalist}
  <tr>



以上代码运行后,之后图中红框的数据可以使用,其他两个都没有效果,请各位大神帮帮小弟,看看怎么解决,谢谢了
HTML

------解决方案--------------------
你是循环生成行的吧,但是你的input框的ID都是id="customtax" ,同一个页面,ID是唯一的啊,所以你看看是不是这个原因
------解决方案--------------------
用jquery 给你写了个 

<html class="">
<head>
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script>
<script>
function setCustomTax(obj)
{
var curRow=$(obj).closest("tr");//获取当前按钮所在行
    var title =$("td[id^='com_title']",curRow).text();
    var price = $("td[id^='com_price']",curRow).text();
    var buynum =$("td[id^='com_buynum']",curRow).text();

    var URL = "mytest.php?title="+title+"&price="+price+"&buynum="+buynum;
    alert(URL);
}</script>
</head>
<body>
<table width="842" border="1" cellpadding="0" cellspacing="0">
<tr>
    <td id="com_title{dede:field.title/}" height="25" align="center" bgcolor="#FFFFFF">{dede:field.title/}</td>
    <td id="com_price{dede:field.price/}" height="25" align="center" bgcolor="#FFFFFF">{dede:field.price/}</td>
    <td id="com_buynum{dede:field.buynum/}" height="25" align="center" bgcolor="#FFFFFF">{dede:field.buynum/}</td>
<td height="25" align="center" bgcolor="#FFFFFF"><input id="customTax{dede:field.title/}" type="button" name="customtax" value="设置" style="width:90px" onClick="javascript:setCustomTax(this);" class='inputTax'></td>
  </tr>

</table>
</body>
</html>