Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
137
rated 0 times [  141] [ 4]  / answers: 1 / hits: 75090  / 12 Years ago, sat, september 29, 2012, 12:00:00

My problem is that I don't know how to show the innerhtml of my form.



The form is like a survey form and once you clicked the submit button, all the contents I had answered would show like a summary page...



function displayResult() {
var first = document.getElementById(first).value;

var middle = document.getElementById(middle).value;

var last = document.getElementById(last).value;

alert(oh);
var maincontent = document.getElementById(content).innerHTML;
maincontent = <p> + first;

}

More From » html

 Answers
16
var maincontent = document.getElementById(content).innerHTML;
maincontent = <p> + first;


On the second line you're overwriting the variable, not setting the .innerHTML. This is what you want:



var maincontent = document.getElementById(content);
maincontent.innerHTML = <p> + first;


Also, you must make sure the elements with ids of first middle and last actually exist, or this might cause a TypeError.


[#82844] Thursday, September 27, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
irvingcarloe

Total Points: 677
Total Questions: 109
Total Answers: 96

Location: Svalbard and Jan Mayen
Member since Sun, Sep 25, 2022
2 Years ago
irvingcarloe questions
Wed, Mar 31, 21, 00:00, 3 Years ago
Tue, Aug 4, 20, 00:00, 4 Years ago
Fri, Jul 3, 20, 00:00, 4 Years ago
;