Reputation: 1337
How do I get this javascript to populate the textarea?
<body onload="form1.submit();"><div align="center">Loading...</div>
<script type="text/javascript" src="<%= g_page_site_actual %>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<%= g_page_site_actual %>/js/jquery.wordstats.js"></script> <!-- core code -->
<script type="text/javascript" src="<%= g_page_site_actual %>/js/jquery.wordstats.en.js"></script> <!-- English stop words -->
<script type="text/javascript">
$(function() {
var count = 20;
$.extend($.wordStats.stopWords, {'retrieved': true, '2007': true});
$.wordStats.computeTopWords(count);
var msgcounttext1 = '<%=completehtml%>'
for(var i = 0, j = $.wordStats.topWords.length; i < j && i <= count; i++) {
msg += $.wordStats.topWords[i].substring(1) + ', ';
}
{
document.form1.textarea.value = document.write(msgcounttext);
}
$.wordStats.clear();
});
</script>
<div id="content" class="hidden"><%=completehtml%>
<form id="form1" name="form1" method="post" action="test.asp">
<textarea name="textarea" id="textarea" cols="45" rows="5"></textarea>
</form>
</div>
</body>
Thanks
Upvotes: 0
Views: 312
Reputation: 700312
The document.write
method isn't used that way, you can just assign the value to the property. You can also use the jQuery val
method to set the text.
Besides, you use three different variables in the code, which I think should be the same:
var msg = '<%=completehtml%>';
for(var i = 0, j = $.wordStats.topWords.length; i < j && i <= count; i++) {
msg += $.wordStats.topWords[i].substring(1) + ', ';
}
$('#textarea').val(msg);
Upvotes: 1
Reputation: 5474
Sample of a JQuery function to do that...
$('a').click(function()
{
$('#textarea').val('Insert this into the Text Area');
//this puts the 'Insert this..' into the text area with the id 'textarea'
})
Upvotes: 2
Reputation: 12545
Besides not having a variable named msgcounttext
, get rid of the document.write
call.
Upvotes: 0