Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

memorize form settings

0 views
Skip to first unread message

artev

unread,
Apr 27, 2008, 10:17:25 AM4/27/08
to
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

VK

unread,
Apr 27, 2008, 10:41:22 AM4/27/08
to

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();

artev

unread,
Apr 27, 2008, 11:02:15 AM4/27/08
to
> <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

Evertjan.

unread,
Apr 27, 2008, 11:05:39 AM4/27/08
to

> .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)

0 new messages