Click to See Complete Forum and Search --> : Initialise Form fields
twanny
04-05-2005, 07:29 AM
Hi, could anybody shed some light of how to initialise fields within a form? I know I can use the Reset functionality and that does what I want BUT that means an extra button to click. If I send a form with some of the fields populated to the server the fields are still populated when I press the BACK buton. Hope this makes sense. regards
onload=document.forms['formName'].reset();
twanny
04-05-2005, 10:39 AM
Thank you for your quick response. Sorry to be a nuisance but I typed in what you suggested but it still doesnt reset my page. Am I right to say that I need to 'name' my form i.e FORM action="xxxxx" name="co11" method="POST" and then put the code u supplied i.e onload= etc between the <script language="JavaScript"> </script> tags? Once again your help is appreciated. Yes and I am a newbie :o
regards
twanny
04-05-2005, 10:49 AM
Oh must apologise. Found out where to put the onload. I put it in as an attribute in the BODY tag. Thanks for your help. :)
fredmv
04-05-2005, 01:24 PM
onload=document.forms['formName'].reset();Believe it or not, this would just set the window.onload property to undefined (the return value of reset). And it would not call it when the page is finished loading, but rather when this line is reached by the interpreter. What you'd want instead is:onload = function() {
// ...
}(Fang, I know you already know this, but this is just so others can learn. ;))
I should have been clearer with my answer. :)