resetting a form when submitting

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

    resetting a form when submitting

    I think that this should be reasonably easy but it is proving to be
    hugely difficult. I am wanting to reset the form to all the original
    values when I submit the form.

    Here is the select box that I wish to reset, so no matter what I
    select, once submitted it will return to 0:

    <select name="hardback" onchange="if(th is.selectedInde x)cover=+(this[this.selectedIn dex].value);">
    <option SELECTED value= "0" > Select Type of Book--(Default
    Paperback)</option>
    <option value="4.00">St andard Hardback</option>
    <option value="6.00">Li mited Edition HardBack</option>

    Here is the line of code that I think will have to be altered.
    <INPUT TYPE="BUTTON" VALUE='Add to Cart'
    onClick="javasc ript:additem('f ootball',
    5.95,1,wrap,cov er);cover=0;wra p=0;">

    I've looked all over this newsgroup but cannot find anything that
    works
    Thanks in advance.
  • McKirahan

    #2
    Re: resetting a form when submitting

    "MickG" <mickg77@hotmai l.com> wrote in message
    news:1a9c775a.0 503241258.1f616 26a@posting.goo gle.com...[color=blue]
    > I think that this should be reasonably easy but it is proving to be
    > hugely difficult. I am wanting to reset the form to all the original
    > values when I submit the form.
    >
    > Here is the select box that I wish to reset, so no matter what I
    > select, once submitted it will return to 0:
    >
    > <select[/color]
    name="hardback" onchange="if(th is.selectedInde x)cover=+(this[this.selectedIn d
    ex].value);">[color=blue]
    > <option SELECTED value= "0" > Select Type of Book--(Default
    > Paperback)</option>
    > <option value="4.00">St andard Hardback</option>
    > <option value="6.00">Li mited Edition HardBack</option>
    >
    > Here is the line of code that I think will have to be altered.
    > <INPUT TYPE="BUTTON" VALUE='Add to Cart'
    > onClick="javasc ript:additem('f ootball',
    > 5.95,1,wrap,cov er);cover=0;wra p=0;">
    >
    > I've looked all over this newsgroup but cannot find anything that
    > works
    > Thanks in advance.[/color]

    Once you "submit a form" you're taken to the page declared by its "action=".

    Aren't you just invoking "additem()" and not really submitting a form?

    I don't think you gave us enough of your code:

    What is "cover", "wrap" and what does "additem()" act on?


    Perhaps all you want to do is either invoke the form's reset method or just
    set the selectedIndex back to 0.


    Comment

    • RobG

      #3
      Re: resetting a form when submitting

      MickG wrote:[color=blue]
      > I think that this should be reasonably easy but it is proving to be
      > hugely difficult. I am wanting to reset the form to all the original
      > values when I submit the form.[/color]
      [...][color=blue]
      > Here is the line of code that I think will have to be altered.
      > <INPUT TYPE="BUTTON" VALUE='Add to Cart'
      > onClick="javasc ript:additem('f ootball',
      > 5.95,1,wrap,cov er);cover=0;wra p=0;">[/color]

      There is nothing here that will submit the form, is it done
      by 'additem()'?

      If you want the 'Add to cart' button to reset the form, then this
      should do the trick (note removal of 'javascript:' pseudo protocol):

      <INPUT TYPE="BUTTON" VALUE='Add to Cart'
      onClick="
      additem('footba ll',5.95,1,wrap ,cover);
      cover=0;
      wrap=0;
      this.form.reset ();
      ">

      --
      Rob

      Comment

      Working...