View Full Version : Clearing one textbox after submit?

11-17-2010, 10:14 PM
I'm trying to have a textbox clear after it has been filled and submitted.
this is my form look....

<form action="" name="webForm" id="webForm">
<div id="title0" class="pageTitle">Enter Student Dropping A Course: </div>
<div id="fieldName">Name: <input type="text" id="fName" name="fName" size="40" maxlength="60" /></div>
<div id="button"><input type="button" value="Add Latest Student To Drop A Course" onclick="addRecord()" /></div>
Sooo...in my javascript i'm coding it like this but for somereason it's not working

function resetForm() {//clear the value in the txt field
document.getElementsById("fName").value = "";


and i have it called from another function here...

function addRecord() {
var old = XMLdoc.getElementsByTagName("studentName")[0]; //Declare var old and set it's value to the elements by tag name
var clone = old.cloneNode(true);
clone.childNodes[0].nodeValue = webForm.elements[0].value; // set clone to value entered by user in text field
XMLdoc.documentElement.appendChild(clone); //append the clone to the document object
any help? ..Much thanks Everyone!

11-17-2010, 10:25 PM
Facepalm moment! Just one tiny syntax error do I see.

getElementsById should be getElementById

11-17-2010, 10:49 PM
It's always helpful to check the js error console. It will save you a lot of time figuring out what the problem is.

11-18-2010, 12:06 AM
LOL...duhhhh!...I totally should've seen that!..I was using getElementsByTagName..copy n paste wasn't my friend on this one. Thankx fer the quick "facePalm" moment :)