473,782 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.

Jul 23 '05 #1
2 1520
"ungvichian " <un********@tha imail.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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.ht m</title>
</head>
<body onload="documen t.form1.first.f ocus()">
<form action="page2.h tm" 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" .
Jul 23 '05 #2


McKirahan wrote:
"ungvichian " <un********@tha imail.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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.ht m</title>
</head>
<body onload="documen t.form1.first.f ocus()">
<form action="page2.h tm" 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="documen t.input.id.focu s()">
<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.repla ce(
unescape(window .location.pathn ame));"></form></body>

Thank you!

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1757
by: Andi B | last post by:
Hi everyone. I have a quick question - if I have a form which refers to a javascript when its submitted using: <form name = "fred" onsubmit = "test()"> and this function creates a popup window to display information in, I find that after the window has appeared, the focus moves back to the form and the text box used to gather user input clears. The clearing text box isnt a
4
1900
by: Albinas | last post by:
Hi all, I am trying to customize the text box to suit the practice of my app. And I am working about the focus behavior of text field. I have met the the following problem. When I set the "tabstop" property of a textbox to "False", the textbox does receive focus when user use the mouse to click. However, if I set the "Enable" property to false,
5
19328
by: Martin | last post by:
I have the following function in the onchange event of several text boxes. If the user enters an invalid number the alert displays. I would like to return the user to that same field after he closes the alert but setting the focus as I'm doing here doesn't do it (instead, the focus goes to the next field). Any suggestions as to hwo I can make this work? Thanks.
1
1765
by: Gill Smith | last post by:
when the page is loaded I am using onload event at the client side and setting the focus on the control(TextBox). However when the user clicks on Clear ImageButton, I am clearing all the text boxes and the grid(previous search result display) in the clicked event of the ImageButton at the server side. How to set the focus on the TextBox again when the user clicks on the Clear button. -Gill
2
1431
by: davemitc | last post by:
How do I focus() to a form-field, from a iframe - to its parent frame?
4
1040
by: Samuel Shulman | last post by:
1. How can I set a button/image as the default so when the user will press on the enter button that specified button/image will receive the event 2. Is there a method that will insert the cursor into a textbox (or set the focus to any other control) Thank you, Samuel
16
1727
by: marc_r_bertrand | last post by:
To all asp/db pros: The quiz code below works. But there is a problem when too many questions are answered (radio buttons clicked). I am not an asp pro. So, is there a pro out there or an amateur guru who will be so kind as to volunteer some time to figure out where the bug is? This may mean he will have to go through the tedious steps of creating an .mdb with a few records...unless the bug is obvious... On a page with server-code...
14
4114
by: shamirza | last post by:
Question Do ActiveX DLLs made in VB still need the VB runtimes on the machine? ________________________________________ Answer In a word, Yes. Visual Basic does not support what is known as "Static
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10311
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8967
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.