을 heres 내 HTML 양식 :JavaScript/HTML : html 본문에 사용자 입력을 표시하는 방법은 무엇입니까?
<label>Name:</label><input type ="text" input id="myName" /><br>
<label>Street:</label><input type="text" input id="myStreet" /><br>
<label>City:</label><input type="text" input id="myCity" /><br>
<label>State:</label> <input type="text" input id="myState" /><br>
<label>Zip:</label> <input type="text" input id="myZip" /><br>
<input type="submit" value="Submit" onclick="myAlert()">
</form>
//my myAlertFunc (from external file)
function myAlert(){
var person = new Person(document.getElementById('myName').value, document.getElementById("myStreet").value, document.getElementById("myCity").value, document.getElementById("myState").value, document.getElementById("myZip").value);
alert(person.getFullAddress());
}
//and my getFullAddress proto from my Person class
Person.prototype.getFullAddress = function() {
return ("Hi, my name is" + " " + this.name + "," + " " + "and my address is:" + " " + this.street + "," + this.city + "," + this.state + "," + this.zip);
};
지금, 온 클릭의 myAlertFunc는 사용자의 입력 값을 알려줍니다. 이 값을 html 본문에 어떻게 표시합니까? 난 그냥 입력 ID가있는 요소를 사용하고 document.getElementById(); 그 id라고 부르기 위해 나는 그 후 무엇을해야하는지 전혀 모른다.
미리 감사드립니다. http://www.w3schools.com/jsref/prop_html_innerhtml.asp이
그래서, 당신의 코드는 다음과 같다 :이 입력
우리는'Person' 함수 선언이 필요합니다. –