我不确定我这样做是否正确:
<div>
<form id="formPost" method="post">
<div id="testdiv">
</div>
</form>
</div>
<div class="actions-left">
<div id="textarea">
<a href="javascript:ShowReplyTextArea();" class="button">Reply</a>
</div>
<div id="postButton">
<a href="javascript:ReplyPost(<%: Model.News.NewsId %>);" class="button">Post</a>
</div>
<div class="clear"></div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#postButton").hide();
});
function ShowReplyTextArea() {
div = document.getElementById("testdiv")
var textArea = document.createElement("textarea");
textArea.rows = 10;
textArea.cols = 10;
textArea.id = "post_textarea";
div.appendChild(textArea);
if ($("#post_textarea").val() != null)
$("#postButton").show();
}
function ReplyPost(newsId)
{
div = document.getElementById("testdiv")
var textArea = document.createElement("textarea");
div.appendChild(textArea);
textArea.id = "reply_textarea";
textArea.value = this.valueOf();;
**var message = textArea.value.toString(); //problem here dont know how???
alert(message);
var jqxhr = $.getJSON("<%= Url.Action("ReplyPost", "Home", new { area = "News" }) %>?newsId=" + newsId + "&message=" + message, function (data) {**
});
}
</script>
然后在我的控制器中:
[HttpGet]
[NoCache]
public JsonResult ReplyPost(int newsId, string message)
{
ZincService.NewsService.ReplyPost(newsId, message);
return Json(new { success = true }, JsonRequestBehavior.AllowGet);
}
特此出处:
<div>
<form id="formPost" method="post">
<div id="testdiv">
</div>
</form>
</div>
<div class="actions-left">
<div id="textarea">
<a href="javascript:ShowReplyTextArea();" class="button">Reply</a>
</div>
<div id="postButton">
<a href="javascript:ReplyPost(116);" class="button">Post</a>
</div>
<div class="clear"></div>
</div>
我如何获得文本区域的值以便我可以传递它,我现在拥有的代码不正确,我做的所有这些都正确吗?我没有看到我输入“sdfgsdfg”的文本的文本区域
谢谢