Reset data

R

Randy Webb

Shabam said:
I have a text field that's pre-filled with data. Suppose the user edits it,
but decides he wants to reset the data back to the original pre-filled data,
how can I do that?

<input type="reset" value="Start Over" />
Thats what a reset button does :)
 
S

Shabam

I have a text field that's pre-filled with data. Suppose the user edits it,
but decides he wants to reset the data back to the original pre-filled data,
how can I do that?
 
S

Shabam

One more thing, is it possible to reset just a subset of items within a form
instead of everything?
 
R

Randy Webb

Shabam said:
Is there a way to do this by a link instead of a button?

Read the FAQ with regards to top-posting.

<a href="" onclick="document.forms['myForm'].reset();return false">Start
Over</a>

Or better, make your button appear as a link (which is a better solution).
 
R

Randy Webb

Shabam said:
One more thing, is it possible to reset just a subset of items within a form
instead of everything?

Read the FAQ with regards to quoting what you are replying to.

And you are wanting to reset certain fields back to there defaults and
leave others alone?

Create an array that contains each fields original value when the page
is loaded along with its default state (if it has one). Then loop
through your form and set the .value or default state of the ones you
want to reset.

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&group=comp.lang.javascript

Is the c.l.j. archives on google, happy searching.

What you want to find is:

1) How to loop through the form elements.
2) How to determine there type/value.
3) How to create an array containing that data.
4) How to "reset" it to its default state.
Hint: That will involve determining its type, looking up its
default state, and then resetting it.

Radio Button, Checkbox, Select, Text Input(includes a textarea).

Hopefully you will find your research an enlightening experience.

If you get stumped, post back with a URL to your un-finished script for
more guidance.
 
S

Shabam

And you are wanting to reset certain fields back to there defaults and
leave others alone?

Create an array that contains each fields original value when the page
is loaded along with its default state (if it has one). Then loop
through your form and set the .value or default state of the ones you
want to reset.

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&group=comp.lang.javascript

Is the c.l.j. archives on google, happy searching.

What you want to find is:

1) How to loop through the form elements.
2) How to determine there type/value.
3) How to create an array containing that data.
4) How to "reset" it to its default state.
Hint: That will involve determining its type, looking up its
default state, and then resetting it.

Radio Button, Checkbox, Select, Text Input(includes a textarea).

Hopefully you will find your research an enlightening experience.

If you get stumped, post back with a URL to your un-finished script for
more guidance.

Thanks for your help. Yes I'm trying to reset just fields back to its
original. I'll do a bit more research and play with it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top