473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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(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
2 1760
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
5
by: Don | last post by:
I have a need to submit a form, but don't need the user to click on a button. How do I do this? Is there some way, using JavaScript, to setup a <form> tag to do this? Thanks, Don ----==...
4
by: Ian Davies | last post by:
Hello I am struggling for a solution to clear some fields on my webpage that takes their values from some sessions My solution below works when the button is clicked twice. I sort of know why I...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
4
by: Super Steve | last post by:
I'm trying to write a little script that disables the submit button on a form, changes the text of the button, and then submits the form. Can anyone tell me why this works ok: <input...
18
by: NavinM | last post by:
I have a couple of forms that are misbehaving in FireFox, but work fine in IE. when i do submit( with submit button) a javascript function validates all of the fields entered, and stops the...
1
by: dittu | last post by:
How to close the popup window when submitting the form? I have a sample.jsp. In that page one button is there. when button pressed, open popup window contains one "text box" and one " submit...
5
by: Rider | last post by:
Hi All, Here is the reason why i ak asking for ur help. I have a edit form in which the values already stored in DB are populated. User can edit some or all the values in the form. then he...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.