memorize form settings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • artev

    memorize form settings

    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:docu ment.getElement ById("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

    #2
    Re: memorize form settings

    On Apr 27, 6:17 pm, artev <mailnotspa...@ notspamm.nnwrot e:
    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:docu ment.getElement ById("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();

    Comment

    • artev

      #3
      Re: memorize form settings

      <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

      Comment

      • Evertjan.

        #4
        Re: memorize form settings

        VK wrote on 27 apr 2008 in comp.lang.javas cript:
        On Apr 27, 6:17 pm, artev <mailnotspa...@ notspamm.nnwrot e:
        >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:doc ument.getElemen tById("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
        >selectedInde x;
        >>
        >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.defaultVal ue;
        };

        resetTextInput( 'myTextInput');

        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        Working...