简体   繁体   English

单击提交按钮时传递textarea的值

[英]Pass value of textarea when submit button is clicked

<textarea id="Comment" type="text" runat="server" rows="7" 
maxlength="2000" />

<input id="SubmitComment" type="button" value="Submit"
onclick="SubmitButton()" /> 

When the user enters data into the textarea and clicks the 'Submit' button I want the data to be passed to the submitButton() where I can then send it on to Functions.CommentBoxForInvoiceUpdates 当用户将数据输入textarea并单击“提交”按钮时,我希望将数据传递给submitButton(),然后我可以将其发送到Functions.CommentBoxForInvoiceUpdates

function SubmitButton() {
var commentBoxData = $('#Comment').val();
Functions.CommentBoxForInvoiceUpdates(id, Labour, commentBoxData);
        } 

Id and Labour are defined earlier so they work fine, 'CommentBoxData' however is showing up as undefined when I run it through a break point. Id和Labor之前已定义,因此它们可以正常工作,但是当我通过断点运行时,'CommentBoxData'显示为未定义。 Any why the data in the comment box is being sent through when submit is clicked? 单击提交时发送评论框中的数据的原因是什么?

Thanks for any ideas 谢谢你的任何想法

You tagged with asp.net. 你用asp.net标记了。 Sure you are using the rendered IDs? 当然你使用渲染的ID?

尝试

var commentBoxData = $('#<%=Comment.ClientID%>').val();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM