Reputation:
When I use this codes, it Prints the result in a new html page, how can I print the results in a nominated textarea? lets I want the result to be shown in: bookForm.myText.value
Update: PLEASE NOTE ONLY THE bTitle IS SUPPOSED TO BE ITALIC
HTML:
<div contenteditable="true"></div>
CSS:
span{
font-style: italic;
}
JavaScript:
bTitle = bookForm.txtTitle.value;
bName = bookForm.txtName.value;
bNumber = bookForm.txtNumber.value;
var concatBook = "<span>"+bTitle+"</span> by "+bName+" sold "+bNumber+" Copies."
$('div').html(concatBook);
Upvotes: 0
Views: 283
Reputation: 1265
Add Textarea in with id "mytext"
<textarea id="mytext" name="somename"></textarea>
Add Javascript
bTitle = bookForm.txtTitle.value;
bName = bookForm.txtName.value;
bNumber = bookForm.txtNumber.value;
var concatBook = ""+bTitle+" by "+bName+" sold "+bNumber+" Copies.";
$('#mytext').val(concatBook); //this will display result in textarea
$('#mytext').css('font-style', 'italic');
Upvotes: 3
Reputation: 1814
Step 1
Create a textarea with id, here id is "myTextarea"
<textarea id="myTextarea" name="somename"></textarea>
Step 2
Javascript
bTitle = bookForm.txtTitle.value; bName = bookForm.txtName.value; bNumber = bookForm.txtNumber.value; var concatBook = ""+bTitle+" by "+bName+" sold "+bNumber+" Copies."; $('#myTextarea').val(concatBook); //this will display result in textarea
Upvotes: 0