Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

提交表单,参数为标签td里的值,如何做到?

<% results.forEach(function(result){%>
    <form action="/buy" method="get" id="second">
        <tr>
          <td id="no"><%=result.no %></td>
          <td><input type="submit" value="购买"></td> 
        </tr>
    </form>
<% }) %>

想把id为no的td里的值作为参数,目前,console.log(req.body.no)打印出来的值是undefined。
新手,如果有更好的建议请不吝赐教,谢谢。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

写个input,type=hidden,value=“<%=result.no%>”就行了,只是用来传数据,不显示


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...