By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,176 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

memorize form settings

P: n/a
when is load a page I have a form with some elements that are
text, textfield, select, select multiple, checks, radios.
where text and textfield are filled with some words,
select have how first elements a specific option,
checkboxses (some are checked) ..
how I can memorize all this initilly settings and recall
with a button if is necessary reinsert all?
I found this but on some select not work (I will make an example)
javascript:document.getElementById("id-form").reset();

in select elements where not work I make a test and also if they are inner
form, only if I write directly code can change the selectedIndex;

I will send a code for test
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
VK
On Apr 27, 6:17 pm, artev <mailnotspa...@notspamm.nnwrote:
when is load a page I have a form with some elements that are
text, textfield, select, select multiple, checks, radios.
where text and textfield are filled with some words,
select have how first elements a specific option,
checkboxses (some are checked) ..

how I can memorize all this initilly settings and recall
with a button if is necessary reinsert all?

I found this but on some select not work (I will make an example)
javascript:document.getElementById("id-form").reset();

in select elements where not work I make a test and also if they are inner
form, only if I write directly code can change the selectedIndex;

I will send a code for test
There should be no problem to use reset() method as long as you don't
have a form element named "reset": in such case you'll a naming
conflict. Possibly this is what you have now, like:
<input type="reset" name="reset" value="reset">
Make sure that your reset button (if presented) is not named "reset".
Otherwise reset() exists exactly for what you are trying to do and it
should work for all browsers up to the most ancient ones, especially
if you use DOM 0 instead:

<form name="MyForm" ...

and then later:

document.forms['MyForm'].reset();

Jun 27 '08 #2

P: n/a
<form name="MyForm" ...
>
and then later:

document.forms['MyForm'].reset();
can found form only by id; but isn't this problem;
problems seem to be that the elemnts are used for make a search;
so first of search if change value the reset() work; after not more;
I think change something in the url;

so would think other solutions:
I think must 'simple' make a cicle of all elements and achieve set inner
variables; so with buttons can reload all the set
Jun 27 '08 #3

P: n/a
VK wrote on 27 apr 2008 in comp.lang.javascript:
On Apr 27, 6:17 pm, artev <mailnotspa...@notspamm.nnwrote:
>when is load a page I have a form with some elements that are
text, textfield, select, select multiple, checks, radios.
where text and textfield are filled with some words,
select have how first elements a specific option,
checkboxses (some are checked) ..

how I can memorize all this initilly settings and recall
with a button if is necessary reinsert all?

I found this but on some select not work (I will make an example)
javascript:document.getElementById("id-form").reset();

in select elements where not work I make a test and also if they are
inner form, only if I write directly code can change the
selectedIndex;

I will send a code for test

There should be no problem to use reset() method as long as you don't
have a form element named "reset": in such case you'll a naming
conflict. Possibly this is what you have now, like:
<input type="reset" name="reset" value="reset">
Make sure that your reset button (if presented) is not named "reset".
Otherwise reset() exists exactly for what you are trying to do and it
should work for all browsers up to the most ancient ones, especially
if you use DOM 0 instead:

<form name="MyForm" ...

and then later:

.reset();
IE [not tested here], perhaps cross browser too, will do:

function resetTextInput(el){
var temp = document.forms['MyForm'].elements[el];
temp.value = temp.defaultValue;
};

resetTextInput('myTextInput');

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.