Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    76
    Thanks
    13
    Thanked 3 Times in 3 Posts

    Clearing one textbox after submit?

    I'm trying to have a textbox clear after it has been filled and submitted.
    this is my form look....
    Code:
    <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>
    </form>
    Sooo...in my javascript i'm coding it like this but for somereason it's not working
    Code:
    function resetForm() {//clear the value in the txt field
        document.getElementsById("fName").value = "";
        
        }
    and i have it called from another function here...
    Code:
    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);
                removeWhiteSpaceNodes(clone);
                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
                displayStudents();
                resetForm();
    ....
    any help? ..Much thanks Everyone!

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,258
    Thanks
    15
    Thanked 255 Times in 255 Posts
    Facepalm moment! Just one tiny syntax error do I see.

    getElementsById should be getElementById

  • Users who have thanked DrDOS for this post:

    joanzn (11-17-2010)

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    It's always helpful to check the js error console. It will save you a lot of time figuring out what the problem is.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New Coder
    Join Date
    Nov 2010
    Posts
    76
    Thanks
    13
    Thanked 3 Times in 3 Posts
    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


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •