Click to See Complete Forum and Search --> : Clearing Forms


sunilaklujkar
08-04-2003, 11:30 PM
Is there any way we can clear the contents of a form. Just as we have a 'cls' command in DOS, similar to that is there any methid which will clear the form?

AdamGundry
08-05-2003, 05:00 AM
You can use Form.reset(), which will reset all the fields in the form to their default values.

Adam

sunilaklujkar
08-05-2003, 05:25 AM
There are no texbox or any such elements on the form. I was to clear a pre-written text.

Khalid Ali
08-05-2003, 10:18 AM
If the form has initial values on load set to its fields for them to be cleared you will have to loop through the form elements and set their value = ""

sunilaklujkar
08-06-2003, 12:52 AM
I guess I am not being clear enough.

Heres an example:
This is what my form looks like when loaded..

----------------------------------------------
Hello People...Welcome to my form


Nice to have u here
----------------------------------------------

Now, in this case, i want to display the first line, and later i want to clear the first line and then display the second line only. There are no form elements present. Just plain text.

Hope this is clear

AdamGundry
08-06-2003, 04:04 AM
If I understand correctly, you can do this:

<div id="container">Hello People...Welcome to my form</div>

<script type="text/javascript">
function changeDiv(){
document.getElementById('container').innerHTML = 'Nice to have u here ';
}
</script>

Adam