Hello,
I have been modifying some javascript shopping basket code and have run into
a problem. I have produced a subset of the HTML/JS that shows the problem
and placed it here: http://dusrc.org/js_test.html
The problem is described on that page but basically 2 event handlers are
being called when I would expect just one to be called.
If someone could explain what I am doing wrong then I would be very
grateful.
Thanks
Deryck 7 1065
1) <input type="image"> is equal by functionality to <input="submit" >
(except it lets you track the click coords within the image)
So except some rare cases, it is always better to use old good linked image
2) If a form contains only one single-line text box, pressing <Enter> within
this box is equal to submit() action.
3) onChange event is called only after the input lost its focus. Evidently
by pressing <Enter> within the textbox you don't remove the focus, so
onChange is never called.
Change the textbox value and click anywhere on the page to see your problem.
You should re-think your model, it's too confusing for browsers.
The best would be:
<form onSubmit="someG lobalCheckOf(th is)">
"VK" <sc**********@y ahoo.com> wrote in message
news:41******** *************** @news.freenet.d e... 1) <input type="image"> is equal by functionality to <input="submit" > (except it lets you track the click coords within the image) So except some rare cases, it is always better to use old good linked image
2) If a form contains only one single-line text box, pressing <Enter> within this box is equal to submit() action.
3) onChange event is called only after the input lost its focus. Evidently by pressing <Enter> within the textbox you don't remove the focus, so onChange is never called. Change the textbox value and click anywhere on the page to see your problem.
Thanks for the above, very educational.
You should re-think your model, it's too confusing for browsers.
It confuses me too!
The best would be:
<form onSubmit="someG lobalCheckOf(th is)">
OK, Thanks again for replying.
Deryck
On Thu, 2 Dec 2004 13:02:38 -0000, Deryck <de****@REMOVEl onghope.co.uk>
wrote:
[snip] If someone could explain what I am doing wrong then I would be very grateful.
You're not doing anything wrong. An image INPUT is a form of submit button
so pressing <Enter> whilst a form control has focus will cause the form to
submit.
As for the errors in Firefox, they would seem to be caused by something
the browser itself is doing, not your actions.
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
On Thu, 2 Dec 2004 16:19:03 +0100, VK <sc**********@y ahoo.com> wrote: 1) <input type="image"> is equal by functionality to <input="submit" > (except it lets you track the click coords within the image) So except some rare cases, it is always better to use old good linked image
I hope you don't mean
<a ... onclick="<formR ef>.submit();"> ...</a>
It that was you're intent, I'd argue that it is *only* in some rare cases
that using a link is better.
[snip]
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
> I hope you don't mean <a ... onclick="<formR ef>.submit();"> ...</a>
I'm too old to take a sin like that on my soul :-))
<a href="void(0)" onClick="someVa lueCheckFun()">
As I remember, it's actually should be
href="someValue CheckFun();canc elBubble=true">
but here we having a standard situation of an old dog and a new trick :-))
On Thu, 2 Dec 2004 18:04:20 +0100, VK <sc**********@y ahoo.com> wrote:
[snip] As I remember, it's actually should be href="someValue CheckFun();canc elBubble=true"> but here we having a standard situation of an old dog and a new trick :-))
The "correct" way is along the lines of
<a href="somewhere-useful.html"
onclick="/* ... */;return false;">...</a>
where somewhere-useful.html is a page you can use to perform the same
thing via the server which the script should have accomplished.
If the script action may fail during execution (due to a missing feature,
for example) the return value should be determined by that script.
The point I was trying to make was that using a link would mean that
action would (probably[1]) become dependent upon scripting.
Mike
[1] If nothing but an instruction and a session id needs to be sent to the
server, a link could handle that fine, but if other information needs to
be sent too, only a form submission would do.
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail. The "correct" way is along the lines of
<a href="somewhere-useful.html" onclick="/* ... */;return false;">...</a>
Thanks, this is what I meant.
And the outdated way (in case anyone follows this thread) is
<a href="javascrip t:void(0)" ... >
I missed "javascript :" in my OP, but doesn't matter: your way is indeed more
functional. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: Daniel |
last post by:
I'm new to .Net and all of its abilities so I hope this makes sense.
Basically I'm confused on when is the appropriate time to use web forms
controls vs. regular HTML.
For example in ASP (non-.Net) if I wanted to fill a list it may look
something like this:
-------START CODE
<%
|
by: bhavik |
last post by:
hi
I have problem that when I am upload my application to the client server, I
am losing buttion event on some pages. on some pages button event is working
fine ro some pages is not working. I am not able to find any solution so
plase help me out this problem.
regards,
bhavik
|
by: Simon Verona |
last post by:
I have a problem in my application which I believe is due to open handles.. .
The symptom that users report is that after they have been using the application for a while, it will randomly just crash with an exception report (I've not got the details of the error, but I'm working on that now!).
I'm trying to reproduce the circumstances by simulating a typical batch of user tasks on my pc and monitoring whats happening. I'm guessing it's...
|
by: chrisdude911 |
last post by:
how do i add video into a javascript web page with my own custom
buttons?
| |
by: Ray |
last post by:
Hello JavaScript experts,
I've been racking my brains for 2 hours and I still haven't figured
out this problem.
Basically, I have this page (an IE-only page), with a lot of
javascript files behind it, most of it not written by me. The problem
with this page is: once I use IE6 to load it, moving the mouse pointer
over the page will cause IE CPU usage to shoot up to 100%. Typing into
edit boxes a lot of characters quickly will also...
|
by: Tomislav |
last post by:
Hello,
I tried to use "javascript:return confirm();" function in following
manner ( triggered by form onSubmit event ):
**
<form method="post" action="mail.php" onSubmit="javascript:return
confirm('Do you really want to send this order ?);">
|
by: maya |
last post by:
hi,
so what is "modern" javascript?? the same as "DOM-scripting"? i.e.,
editing content (or changing appearance of content) dynamically by
massaging javascript objects, html elements, etc? (in conjunction with
css, you know, the usual...;) this is what is meant by "modern"
javascript?? so how do folks feel about this who think javascript is so
evil they disable it from their browsers?? do sites designed with
"modern" javascript...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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,...
| |
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...
|
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();...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |