473,503 Members | 939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form or Javascript Problem

On my web site, indicated below, go to the yearly calendar page. Upon
entry it shows the current year. The arrows at the top make it go
forward and backward. If you put a date into the little box and click
outside the box it creates that year. If you put a date in the box and
press return the calendar is drawn and then the page immediately
reloads. Why?

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #1
4 1100
Dennis M. Marks wrote:
On my web site, indicated below, go to the yearly calendar page. Upon
entry it shows the current year. The arrows at the top make it go
forward and backward. If you put a date into the little box and click
outside the box it creates that year. If you put a date in the box and
press return the calendar is drawn and then the page immediately
reloads. Why?


I believe this is standard behavior when you have only one text box in a
form, a return acts like a form submit.

If you add a second textbox (including hidden textboxes) I believe this
will stop happening, but the calendars won't redraw when you hit return
in the first text box anymore. You might add a button next to the text
box to call the function if you use this approach, or watch for the
return keypress in the textbox.

<input type="text" value="test0" style="visibility:hidden;">

Mike

Jul 23 '05 #2
Fox


"Dennis M. Marks" wrote:

On my web site, indicated below, go to the yearly calendar page. Upon
entry it shows the current year. The arrows at the top make it go
forward and backward. If you put a date into the little box and click
outside the box it creates that year. If you put a date in the box and
press return the calendar is drawn and then the page immediately
reloads. Why?
forms automatically "submit" when the user types Enter (if focus is in a
form field), unless directed otherwise.

try:

<form onsubmit = "return false">

it's better to have the form respond to the user typing return, so your
form should call the createCalendar routine onsubmit. You will still
need to "return false" either from the function itself, or as a second
statement to the onsubmit property:

<form onsubmit = "createCalendar(arglist); return false"> or have
createCalendar(..) { ... return false; } and <form onsubmit = "return createCalendar(arglist)">

Fox
*****************


--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Jul 23 '05 #3
On Sun, 18 Apr 2004 19:56:01 -0700, Dennis M. Marks
<de******@domain.invalid> wrote:
On my web site, indicated below, go to the yearly calendar page. Upon
entry it shows the current year. The arrows at the top make it go
forward and backward. If you put a date into the little box and click
outside the box it creates that year. If you put a date in the box and
press return the calendar is drawn and then the page immediately
reloads. Why?


The others have indicated why, but have given unnecessarily complicated
solutions. Simply remove the FORM element. You don't use it, and it's
invalid mark-up, too. FORM elements are only required to submit values[1],
not to contain form controls.

Mike
[1] You could also use them for ease of reference, rather than relying on
getElementById(), and the like.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #4
In article <op**************@news-text.blueyonder.co.uk>, Michael
Winter <M.******@blueyonder.co.invalid> wrote:
On Sun, 18 Apr 2004 19:56:01 -0700, Dennis M. Marks
<de******@domain.invalid> wrote:
On my web site, indicated below, go to the yearly calendar page. Upon
entry it shows the current year. The arrows at the top make it go
forward and backward. If you put a date into the little box and click
outside the box it creates that year. If you put a date in the box and
press return the calendar is drawn and then the page immediately
reloads. Why?


The others have indicated why, but have given unnecessarily complicated
solutions. Simply remove the FORM element. You don't use it, and it's
invalid mark-up, too. FORM elements are only required to submit values[1],
not to contain form controls.

Mike
[1] You could also use them for ease of reference, rather than relying on
getElementById(), and the like.


Thanks for all the advice. The best method was as follows:

<form onsubmit="return false">
Enter year and click create <input type="text" size="5" maxlength="4"
onchange="y=this.value; initPage()" />
<input type="submit" value="create"/ >
</form>

The submit button doesn't really do anything but it gives a place to
click outside the box.

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #5

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

Similar topics

0
1443
by: Ronan | last post by:
Hi, I have a problem with a form using the PHP PEAR HTML_QuickForm package & javascript: I want to record the content of my form into a mySQL database then execute a javascript function. ...
2
3403
by: Bill S. | last post by:
Hi, I am just starting to work with ASP, so bear that in mind... I have an ASP page that displays records from a table, and allows you to add, update and delete. There is a form with one...
13
40624
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
7
4856
by: Randell D. | last post by:
Folks, I am working on a contact db using PHP and MySQL. My results so far outputs a slimed down version of records to the browser. I would like to implement a method whereby the user can...
0
1871
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
27
4679
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
3
2038
by: Athmaus | last post by:
Hello, I have this ecom page that i am making where customers can select to choose additional licenses before they purchase. I have that part working with javascript. Problem is that when the...
11
2961
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...
19
3270
by: klenwell | last post by:
Another request for comments here. I'd like to accomplish something like the scheme outlined at this page here: http://tinyurl.com/3dtcdr In a nutshell, the form uses javascript to hash...
0
3366
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
0
7203
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,...
0
7282
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,...
0
7339
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...
1
6995
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...
0
4678
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...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
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 ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.