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

resetting a form when submitting

P: n/a
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)cov er=+(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.
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"MickG" <mi*****@hotmail.com> wrote in message
news:1a**************************@posting.google.c om...
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)cov er=+(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.
Jul 23 '05 #2

P: n/a
MickG wrote:
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();
">

--
Rob
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.