The title may not be correct, I'm not sure how to phrase the question intelligently. May have to do with a lack of intelligence... anyhoo: As part of a CMS, I have this javascript function that generates a preview of data entered into an HTML form textarea. Now, the form obviously contains more parts than just this textarea and I would like to extend the function to include variables for "title" and "summary" as well. Not knowing javascript, I'm stuck as to how to do this. So if any kind soul out there feels like educating me (preferably with visual example and not just "well you've gotta put the thing in the stuff and wiggle...") I would be most grateful.
The function I have is this:
// generate preview
function updatePreview() {
if (document.getElementById('txt')) {
var body = document.getElementById('txt').value;
document.getElementById('preview').innerHTML = body;
}
}
The title's form field is named "title" and the summary textarea is named "sumtxt" so the imagined function would be something like:
// generate preview
function updatePreview() {
if (document.getElementById('title')+('txt')+('sumtxt')) {
var body = document.getElementById('title')+('txt')+('sumtxt').value;
document.getElementById('preview').innerHTML = body;
}
}
... but that doesn't look especially right, even to me. Suggestions? Thanks.