Hi,
I have an image in my HTML form which has onclick() handler. There is
also a submit button and a text box.
Whenever text box has focus and user presses enter, the onclick() event
of image is fired with event.keyCode as undefined. I was expecting that
the form would get submitted.
I tried returning from onclick() handler if keyCode is null, but the
event does not propagate further. Does anybody know solution to this?
Thanks,
Sameer 4 13562 sa******@gmail. com wrote:
Hi,
I have an image in my HTML form which has onclick() handler. There is
also a submit button and a text box.
Whenever text box has focus and user presses enter, the onclick() event
of image is fired with event.keyCode as undefined. I was expecting that
the form would get submitted.
If you press 'enter' on the text box that's in a form, then by default
the form will get submitted. The onclick event on your image should
not be triggered.
I tried returning from onclick() handler if keyCode is null, but the
event does not propagate further. Does anybody know solution to this?
As said before, your image is not even being clicked on, why would you
expect to trigger the event handler? Without knowing what you're
trying to achieve, there isn't much to go on. Explain what you're
trying to achieve and a minimal set of code which your problem occurs.
web.dev wrote:
sa******@gmail. com wrote:
Hi,
I have an image in my HTML form which has onclick() handler. There is
also a submit button and a text box.
Whenever text box has focus and user presses enter, the onclick() event
of image is fired with event.keyCode as undefined. I was expecting that
the form would get submitted.
If you press 'enter' on the text box that's in a form, then by default
the form will get submitted. The onclick event on your image should
not be triggered.
This is what I am expecting (i.e. form should get submitted), but
instead image's onclick handler is called. (This is happening in
FireFox 1.5.0.6 and not in IE 7.0.5296)
>
I tried returning from onclick() handler if keyCode is null, but the
event does not propagate further. Does anybody know solution to this?
As said before, your image is not even being clicked on, why would you
expect to trigger the event handler? Without knowing what you're
trying to achieve, there isn't much to go on. Explain what you're
trying to achieve and a minimal set of code which your problem occurs.
Here is some sample code
<html>
<script language="javas cript">
function validateForm(fo rmObj)
{
alert("Submitti ng form");
return true;
}
function handleImageClic k()
{
alert("In handleImageClic k");
return true;
}
</script>
<body>
<form action="dummy" onSubmit="retur n validateForm(th is);">
<input type="text" id="id_date" />
<input type='image' src='icon_calen dar.gif'
height='16' width='16'
alt='Select Date'
onclick='handle ImageClick()' border='0' />
<input type="submit" />
</form>
</body>
</html>
What I have observed is that the form does get submitted in FF, but
before that onclick()
handler is also called. In my real application, that opens up a pop-up
calendar
which we don't want when user presses enter to submit the form.
Thanks,
Sameer sa******@gmail. com wrote:
web.dev wrote:
sa******@gmail. com wrote:
Hi,
>
I have an image in my HTML form which has onclick() handler. There is
also a submit button and a text box.
>
Whenever text box has focus and user presses enter, the onclick() event
of image is fired with event.keyCode as undefined. I was expecting that
the form would get submitted.
If you press 'enter' on the text box that's in a form, then by default
the form will get submitted. The onclick event on your image should
not be triggered.
This is what I am expecting (i.e. form should get submitted), but
instead image's onclick handler is called. (This is happening in
FireFox 1.5.0.6 and not in IE 7.0.5296)
I tried returning from onclick() handler if keyCode is null, but the
event does not propagate further. Does anybody know solution to this?
As said before, your image is not even being clicked on, why would you
expect to trigger the event handler? Without knowing what you're
trying to achieve, there isn't much to go on. Explain what you're
trying to achieve and a minimal set of code which your problem occurs.
Here is some sample code
<html>
<script language="javas cript">
The language attribute is deprecated, use the type attribute instead:
<script type = "text/javascript">
function validateForm(fo rmObj)
{
alert("Submitti ng form");
return true;
}
function handleImageClic k()
{
alert("In handleImageClic k");
return true;
}
</script>
<body>
<form action="dummy" onSubmit="retur n validateForm(th is);">
<input type="text" id="id_date" />
<input type='image' src='icon_calen dar.gif'
height='16' width='16'
alt='Select Date'
onclick='handle ImageClick()' border='0' />
<input type="submit" />
</form>
</body>
</html>
What I have observed is that the form does get submitted in FF, but
before that onclick()
handler is also called. In my real application, that opens up a pop-up
calendar
which we don't want when user presses enter to submit the form.
Thanks,
Sameer
I see nothing out of the ordinary, except for perhaps missing <head>
elements. Tested in IE 6 and IE 7.0.5520. In both cases, the form
gets submitted. One thing you should note is that an input element
with its type set to image is the same as a submit button, just
graphical. Therefore, there is no need to set an onclick event
handler, nor do you need the second submit button. Just use the
onsubmit event handler on your form.
web.dev wrote:
sa******@gmail. com wrote:
web.dev wrote:
sa******@gmail. com wrote:
Hi,
I have an image in my HTML form which has onclick() handler. There is
also a submit button and a text box.
Whenever text box has focus and user presses enter, the onclick() event
of image is fired with event.keyCode as undefined. I was expecting that
the form would get submitted.
>
If you press 'enter' on the text box that's in a form, then by default
the form will get submitted. The onclick event on your image should
not be triggered.
This is what I am expecting (i.e. form should get submitted), but
instead image's onclick handler is called. (This is happening in
FireFox 1.5.0.6 and not in IE 7.0.5296)
>
I tried returning from onclick() handler if keyCode is null, but the
event does not propagate further. Does anybody know solution to this?
>
As said before, your image is not even being clicked on, why would you
expect to trigger the event handler? Without knowing what you're
trying to achieve, there isn't much to go on. Explain what you're
trying to achieve and a minimal set of code which your problem occurs.
Here is some sample code
<html>
<script language="javas cript">
The language attribute is deprecated, use the type attribute instead:
<script type = "text/javascript">
function validateForm(fo rmObj)
{
alert("Submitti ng form");
return true;
}
function handleImageClic k()
{
alert("In handleImageClic k");
return true;
}
</script>
<body>
<form action="dummy" onSubmit="retur n validateForm(th is);">
<input type="text" id="id_date" />
<input type='image' src='icon_calen dar.gif'
height='16' width='16'
alt='Select Date'
onclick='handle ImageClick()' border='0' />
<input type="submit" />
</form>
</body>
</html>
What I have observed is that the form does get submitted in FF, but
before that onclick()
handler is also called. In my real application, that opens up a pop-up
calendar
which we don't want when user presses enter to submit the form.
Thanks,
Sameer
I see nothing out of the ordinary, except for perhaps missing <head>
elements. Tested in IE 6 and IE 7.0.5520. In both cases, the form
gets submitted. One thing you should note is that an input element
with its type set to image is the same as a submit button, just
graphical. Therefore, there is no need to set an onclick event
handler, nor do you need the second submit button. Just use the
onsubmit event handler on your form.
This does not work in FireFox, but I guess that IS the expected
behaviour since you said that input type="image" is treated as a submit
button. So IE is misbehaving.
In our application, we want that image to open up a calendar and a
separate submit would submit the form.
So I modified our code not to use input type="image" and use <atag
with onclick="openCa lendar()"
Thanks for your quick responses web.dev,
Sameer This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Zalek Bloom |
last post by:
Hello,
Here is my problem:
I am displaying to a user a row of buttons. Depending on which button
user presses, I want to go to a different URL and to give a different
value to a hidden variable.
My code is:
<FORM NAME=FORM1 ACTION="">
<input type="button" name="B1" onclick="ModC('1')">
|
by: Andy Goldstein |
last post by:
I have a table where all the TRs have an onClick handler registered.
One (and only one) of the rows has 2 text input boxes, where each
textbox has an onChange handler registered. Both the onClick and
onChange handlers do some minor manipulation of form data (although
they work on different form elements). If the onChange event fires, I
need the form to be submitted. If the onClick event fires for a TR, I
also need the form to be...
|
by: f1crazed |
last post by:
Hello,
I am wanting to fire the onClick event of button1 by pressing button2.
Does anyone have a clue if this is even posible? If so PLEASE HELP!!
Thanks.
|
by: Mark Rae |
last post by:
Hi,
VS.NET 2003 on WinXPPro, both with all the latest patches and updates,
etc...
I've got a very simple WebForm which is used either to add a new record to a
SQL Server database or edit a record. Depending on whether I'm adding or
editing, I need to do slightly different validation, so I'm trying to set
the form's Save button's onclick property dynamically at run-time
client-side with JavaScript, as follows:
|
by: dickson.matt |
last post by:
OK, I am checking the values of a radiobuttonlist with 2 values (Yes
and No) using javascript:
<table id="optMedTreatment"
onClick="SetFocusDayPhone(document.getElementsByName('optMedTreatment'))">
<tr>
<td><input id="optMedTreatment_0" type="radio" name="optMedTreatment"
value="Yes" /><label for="optMedTreatment_0">Yes</label></td>
</tr><tr>
<td><input id="optMedTreatment_1" type="radio" name="optMedTreatment"
| |
by: extremerep |
last post by:
My task is to change the value of a button and then make it functional
with the onClick handler. Changing the value to "Play Again" works, but
making the onClick work accordingly does not. The following is a
snippet of the script. What is keeping it from working?
function displaycards1(){
document.form1.reveal1.value="Play Again";
document.form1.reveal1.onClick="setcards();";
}
</script>
|
by: Jacqui |
last post by:
Hi,
I am trying to write a webpage that has a form on it, which gets
submitted when a button is pressed, but also has an onclick event
which does some DOM manipulation to display a waiting page.
The issue that I am facing is that in Safari, a blank screen is being
displayed rather than the waiting page. This is only happening if
there are form tags around the button
|
by: dangt85 |
last post by:
Hello,
I have the following page:
...
<style type="text/css">
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
|
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: 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...
|
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...
| |
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: 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...
| |