straygrey Posted April 23, 2007 Share Posted April 23, 2007 I have written a Javascript script as follows:- function ClearForm() { document.getElementById("CardNumber").innerHTML = ""; document.getElementById("MemberName").innerHTML = ""; document.getElementById("Amount").innerHTML = " "; document.getElementById("Reason").innerHTML = " "; document.getElementById("Issue").disabled=true; document.getElementById("CardNumber").focus(); } and am confused as to why CardNumber and MemberName get cleared but Amount and Reason do not. All fields are defined in HTML as :- <input type=text with a name as well as an id. They are all defined within their individual <div> Quote Link to comment Share on other sites More sharing options...
fenway Posted April 23, 2007 Share Posted April 23, 2007 <shudder> Why not just reset those elements? Quote Link to comment Share on other sites More sharing options...
straygrey Posted April 23, 2007 Author Share Posted April 23, 2007 I have set document.all.Adjustments.reset(); as well as document.Adjustments.Amount.reset(); and I still have the same problem. I also do not understanding what help your <shudder> included. Please explain. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted April 23, 2007 Share Posted April 23, 2007 change this function ClearForm() { document.getElementById("CardNumber").innerHTML = ""; document.getElementById("MemberName").innerHTML = ""; document.getElementById("Amount").innerHTML = " "; document.getElementById("Reason").innerHTML = " "; document.getElementById("Issue").disabled=true; document.getElementById("CardNumber").focus(); } for this function ClearForm() { document.myForm.reset(); } changing myForm to the name of the form you are using Quote Link to comment Share on other sites More sharing options...
straygrey Posted April 23, 2007 Author Share Posted April 23, 2007 I have tried that as well and still it fails. function ClearForm() { document.Adjustments.reset(); } and I have <title> Adjustments </title> as well as <form name="Adjustments" ID="Adjustments" method="get" action="InsertAdjustment.php"> in the HTML page. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 23, 2007 Share Posted April 23, 2007 I also do not understanding what help your <shudder> included. Please explain. You are using .innerHTML to change form elements! Quote Link to comment Share on other sites More sharing options...
straygrey Posted April 23, 2007 Author Share Posted April 23, 2007 Please tell me how it should it be done. As you can see above I have attempted reset without success. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted April 23, 2007 Share Posted April 23, 2007 try this then function ClearForm() { document.getElementById("CardNumber").value = ""; document.getElementById("MemberName").value = ""; document.getElementById("Amount").value= ""; document.getElementById("Reason").value= ""; document.getElementById("Issue").disabled=true; document.getElementById("CardNumber").focus(); } Quote Link to comment Share on other sites More sharing options...
fenway Posted April 23, 2007 Share Posted April 23, 2007 Yup, that's the idea... sorry I wasn't clear. Quote Link to comment Share on other sites More sharing options...
straygrey Posted April 24, 2007 Author Share Posted April 24, 2007 Despite making these changes Amount & Reason still do not clear. In the web page they are defined as :- echo '<div style="position:relative;"><input type=text name="Amount" id="Amount" onBlur="CheckAmount()"></div>'; echo '<div style="position:relative;"><input type=text name="Reason" id="Reason" onBlur="CheckReason()"></div>'; Quote Link to comment Share on other sites More sharing options...
fenway Posted April 24, 2007 Share Posted April 24, 2007 Well, assume it can find the element, there should be no reason. Quote Link to comment Share on other sites More sharing options...
straygrey Posted April 25, 2007 Author Share Posted April 25, 2007 I have resolved the problem by doing a partial rewrite and eliminating most of the Javascript. Thank you all for your suggestions and help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.