resetting a form when submitting

M

MickG

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(this.selectedIndex)cover=+(this[this.selectedIndex].value);">
<option SELECTED value= "0" > Select Type of Book--(Default
Paperback)</option>
<option value="4.00">Standard Hardback</option>
<option value="6.00">Limited 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="javascript:additem('football',
5.95,1,wrap,cover);cover=0;wrap=0;">

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

McKirahan

MickG said:
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(this.selectedIndex)cover=+(this[this.selectedInd
ex].value);">
<option SELECTED value= "0" > Select Type of Book--(Default
Paperback)</option>
<option value="4.00">Standard Hardback</option>
<option value="6.00">Limited 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="javascript:additem('football',
5.95,1,wrap,cover);cover=0;wrap=0;">

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

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

RobG

MickG said:
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 line of code that I think will have to be altered.
<INPUT TYPE="BUTTON" VALUE='Add to Cart'
onClick="javascript:additem('football',
5.95,1,wrap,cover);cover=0;wrap=0;">

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('football',5.95,1,wrap,cover);
cover=0;
wrap=0;
this.form.reset();
">
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top