Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Two JS questions in one: giving focus, and clearing form (read inside)

Reply
Thread Tools

Two JS questions in one: giving focus, and clearing form (read inside)

 
 
ungvichian
Guest
Posts: n/a
 
      05-25-2005
Okay, how do I write a page with a form so that when I click Submit,
the following happens?

1. The data is submitted (of course)
2. The form is cleared (what I've tried results in the form being
cleared first, resulting in an empty submission), and
3. The cursor goes back to the start of the form, ready for more input
(kind of like how Google puts the cursor in the search box at the
start).

I can't seem to find the answer, and I've been looking on the net for a
few hours already.

 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      05-25-2005
"ungvichian" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Okay, how do I write a page with a form so that when I click Submit,
> the following happens?
>
> 1. The data is submitted (of course)
> 2. The form is cleared (what I've tried results in the form being
> cleared first, resulting in an empty submission), and
> 3. The cursor goes back to the start of the form, ready for more input
> (kind of like how Google puts the cursor in the search box at the
> start).
>
> I can't seem to find the answer, and I've been looking on the net for a
> few hours already.
>


Say your page is like this:

<html>
<head>
<title>page1.htm</title>
</head>
<body onload="document.form1.first.focus()">
<form action="page2.htm" method="get" name="form1">
<input type="text" name="first">
<input type="text" name="second">
<input type="text" name="third">
<input type="submit" value="Submit">
</form>
</body>
</html>

When "page2.htm" is done processing the form just have it call "page1.htm".


 
Reply With Quote
 
 
 
 
ungvichian@thaimail.com
Guest
Posts: n/a
 
      05-26-2005


McKirahan wrote:
> "ungvichian" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > Okay, how do I write a page with a form so that when I click Submit,
> > the following happens?
> >
> > 1. The data is submitted (of course)
> > 2. The form is cleared (what I've tried results in the form being
> > cleared first, resulting in an empty submission), and
> > 3. The cursor goes back to the start of the form, ready for more input
> > (kind of like how Google puts the cursor in the search box at the
> > start).
> >
> > I can't seem to find the answer, and I've been looking on the net for a
> > few hours already.
> >

>
> Say your page is like this:
>
> <html>
> <head>
> <title>page1.htm</title>
> </head>
> <body onload="document.form1.first.focus()">
> <form action="page2.htm" method="get" name="form1">
> <input type="text" name="first">
> <input type="text" name="second">
> <input type="text" name="third">
> <input type="submit" value="Submit">
> </form>
> </body>
> </html>
>
> When "page2.htm" is done processing the form just have it call "page1.htm".


I've adapted your solution, but I made it so that the submit button
simply reloads the form upon submission (and I found that at another
page). Source:

<body onload="document.input.id.focus()">
<form name = "input" method = "post" action = "<?php echo
$_SERVER['PHP_SELF'];?>" target=content>
ID: <input type="Text" name="id" size=7 maxlength=7> <input
type="Submit" name="submit" value="Submit"
OnClick="window.location.replace(
unescape(window.location.pathname));"></form></body>

Thank you!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The giving that keeps on giving sixteenmillion C Programming 0 11-19-2007 10:59 PM
ObjectDataSource & FormView adding two extra paramaters to Update method giving error non-generic method ... Fred Dag ASP .Net 0 09-18-2006 10:36 PM
multiplying two numbers and giving the square root John Cho C++ 4 06-14-2006 07:57 PM
multiplying two numbers and giving the square root David Harmon C++ 2 06-14-2006 07:56 PM
Cache clearing deletes saved form info and history. Anyway not to have this happen? Jim Firefox 4 05-05-2005 06:15 AM



Advertisments