Forum Moderators: phranque

Message Too Old, No Replies

Clear form fields after submit.

         

bpositive

5:14 pm on Jul 29, 2003 (gmt 0)

10+ Year Member



Hello,
I have a form to my web based email page that:
1- I use an image as my submit button
2- I set target=_blank to open a new window after submitting

When users close the new window after checking their emails, they will see the original page that contained the form with all the fields filled.

Is there a way to submit the form and clear all the fields at the same time?

Thanks

Be Positive

AWildman

5:37 pm on Jul 29, 2003 (gmt 0)

10+ Year Member



You could add a bit of javascript to your button onclick that would clear your form then return true so that your form can be submitted.

bpositive

6:46 pm on Jul 29, 2003 (gmt 0)

10+ Year Member



Thank you for your reply.
Here is my code:

<input type=image name=submit src="images/login.gif">

Where should I put the Javascript?

I think I cannot use onclick because I am not using an HTML button and I am using an image button. right?

txbakers

3:13 pm on Aug 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you can use onClick on any HTML form element.

instead of using input type = image, just use an <a href=# onClick=""><img src="yourimage"></a>

AWildman

4:14 pm on Aug 5, 2003 (gmt 0)

10+ Year Member



Here's a bit of useful code:

<form name = "formname" method = "post" action = "/scripts/somedir/some.pl" onsubmit = "return final_check()">
<input type = "hidden" name = "to" value = "">
<input type = "hidden" name = "data1" value = "">
<input type = "hidden" name = "data2" value = "">
<input type = "submit" value = "Submit">
<input type = "button" value = "Clear Form" onclick = "clearcart()">
</form>

1. The form's onsubmit does a validation check BEFORE submitting. The final_check() function can obviously include a call to a function that clears the cart.
2. A form button uses an onclick to clear the cart.