473,395 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

onClick vs Enter Key

art

Hi,

I have a form with an image button like this:

<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>

Problem is that the mouse click works fine. The enter key, once you
enter data and hit enter, nothing happens. I want it to work with
both the enter key AND the mouse......

Can someone help me out here?

Thanks!
Jun 27 '08 #1
10 4152
On Jun 3, 5:21 pm, "a...@unsu.com" <ame...@iwc.netwrote:
Hi,

I have a form with an image button like this:

<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>

Problem is that the mouse click works fine. The enter key, once you
enter data and hit enter, nothing happens. I want it to work with
both the enter key AND the mouse......
Add an onKeyPress event handler for the INPUT element and check for
the user pressing Enter.
Jun 27 '08 #2
On Jun 3, 5:48*pm, Dan Rumney <danrum...@warpmail.netwrote:
On Jun 3, 5:21 pm, "a...@unsu.com" <ame...@iwc.netwrote:
Hi,
I have a form with an image button like this:
<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>
Problem is that the mouse click works fine. *The enter key, once you
enter data and hit enter, nothing happens. *I want it to work with
both the enter key AND the mouse......

Add an onKeyPress event handler for the INPUT element and check for
the user pressing Enter.
How do I check for the enter key??? I'm a bit lost there......
Jun 27 '08 #3
On Jun 3, 5:48*pm, Dan Rumney <danrum...@warpmail.netwrote:
On Jun 3, 5:21 pm, "a...@unsu.com" <ame...@iwc.netwrote:
Hi,
I have a form with an image button like this:
<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>
Problem is that the mouse click works fine. *The enter key, once you
enter data and hit enter, nothing happens. *I want it to work with
both the enter key AND the mouse......

Add an onKeyPress event handler for the INPUT element and check for
the user pressing Enter.

How about something like this:

<td><input type='text' name='email' id='email' value='' size=30
onKeyDown="if(event.KkeyCode==13)
{event.keyCode=9;getCustomer(custform.email.value) ;return
false;}"><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/email.gif' border=0 onclick='return
getCustomer(custform.email.value);'></a><BR><BR></td>

Only problem is that once you press enter, it does what it is supposed
to, then clears the screen. I do not want the screen to clear.......
Jun 27 '08 #4
On Jun 3, 9:40 pm, Mtek <m...@mtekusa.comwrote:
On Jun 3, 5:48 pm, Dan Rumney <danrum...@warpmail.netwrote:
On Jun 3, 5:21 pm, "a...@unsu.com" <ame...@iwc.netwrote:
Hi,
I have a form with an image button like this:
<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>
Problem is that the mouse click works fine. The enter key, once you
enter data and hit enter, nothing happens. I want it to work with
both the enter key AND the mouse......
Add an onKeyPress event handler for the INPUT element and check for
the user pressing Enter.

How about something like this:

<td><input type='text' name='email' id='email' value='' size=30
onKeyDown="if(event.KkeyCode==13)
{event.keyCode=9;getCustomer(custform.email.value) ;return
false;}"><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/email.gif' border=0 onclick='return
getCustomer(custform.email.value);'></a><BR><BR></td>

Only problem is that once you press enter, it does what it is supposed
to, then clears the screen. I do not want the screen to clear.......
If you could provide all details of the page and code involved, we
might be able to help here.

Thanks
Jun 27 '08 #5
On Jun 3, 9:35*pm, Dan Rumney <danrum...@warpmail.netwrote:
On Jun 3, 9:40 pm, Mtek <m...@mtekusa.comwrote:


On Jun 3, 5:48 pm, Dan Rumney <danrum...@warpmail.netwrote:
On Jun 3, 5:21 pm, "a...@unsu.com" <ame...@iwc.netwrote:
Hi,
I have a form with an image button like this:
<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>
Problem is that the mouse click works fine. *The enter key, once you
enter data and hit enter, nothing happens. *I want it to work with
both the enter key AND the mouse......
Add an onKeyPress event handler for the INPUT element and check for
the user pressing Enter.
How about something like this:
<td><input type='text' name='email' id='email' value='' size=30
onKeyDown="if(event.KkeyCode==13)
{event.keyCode=9;getCustomer(custform.email.value) ;return
false;}"><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/email.gif' border=0 onclick='return
getCustomer(custform.email.value);'></a><BR><BR></td>
Only problem is that once you press enter, it does what it is supposed
to, then clears the screen. *I do not want the screen to clear.......

If you could provide all details of the page and code involved, we
might be able to help here.

Thanks- Hide quoted text -

- Show quoted text -

Well, the code above is what I use to call the function. Here is the
function:

<script>
var isIE = false;
var req = '';

// Get the customer to be opted out
function getCustomer(pemail) {
document.getElementById('innerb').style.display="n one";
var strURL="./xml/custform.php?pemail="+pemail;
req = new XMLHttpRequest(true);
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) { // only if "OK"
if (req.status == 200) {

document.getElementById('innerb').innerHTML=req.re sponseText;
document.getElementById('innerb').style.display="" ;
} else {
alert("There was a problem while using XMLHttpRequest:
\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}

</script>

Hope that helps, and thanks.

John
Jun 27 '08 #6
ar*@unsu.com wrote:
Hi,

I have a form with an image button like this:

<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>

Problem is that the mouse click works fine. The enter key, once you
enter data and hit enter, nothing happens. I want it to work with
both the enter key AND the mouse......

Can someone help me out here?

Thanks!
If this is inside a form where the action is specified as where you
really want the # to be, what happens if you change <imgto <input
type="image">?
Jun 27 '08 #7
On Jun 4, 10:28*am, sheldonlg <sheldonlgwrote:
a...@unsu.com wrote:
Hi,
I have a form with an image button like this:
<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>
Problem is that the mouse click works fine. *The enter key, once you
enter data and hit enter, nothing happens. *I want it to work with
both the enter key AND the mouse......
Can someone help me out here?
Thanks!

If this is inside a form where the action is specified as where you
really want the # to be, what happens if you change <imgto <input
type="image">?- Hide quoted text -

- Show quoted text -
If I change it to type = image, and no go. IE only performs the MySQL
update on the first time. And, although I've put echo statements in
the code and it looks like everything is updating, the actual values
in the database are never changed. I even do a COUNT(*) afterwards to
check and echo that result, and it says it changed, but never any
changes occus after the first time.......totally stumped on this one.

Jun 27 '08 #8
Mtek wrote:
On Jun 4, 10:28 am, sheldonlg <sheldonlgwrote:
>a...@unsu.com wrote:
>>Hi,
I have a form with an image button like this:
<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>
Problem is that the mouse click works fine. The enter key, once you
enter data and hit enter, nothing happens. I want it to work with
both the enter key AND the mouse......
Can someone help me out here?
Thanks!
If this is inside a form where the action is specified as where you
really want the # to be, what happens if you change <imgto <input
type="image">?- Hide quoted text -

- Show quoted text -

If I change it to type = image, and no go. IE only performs the MySQL
update on the first time. And, although I've put echo statements in
the code and it looks like everything is updating, the actual values
in the database are never changed. I even do a COUNT(*) afterwards to
check and echo that result, and it says it changed, but never any
changes occus after the first time.......totally stumped on this one.
Are you using a MySQL database or are you using one like Oracle that
requires and explicit commit?
Jun 27 '08 #9
On Jun 4, 3:33*pm, sheldonlg <sheldonlgwrote:
Mtek wrote:
On Jun 4, 10:28 am, sheldonlg <sheldonlgwrote:
a...@unsu.com wrote:
Hi,
I have a form with an image button like this:
<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>
Problem is that the mouse click works fine. *The enter key, once you
enter data and hit enter, nothing happens. *I want it to work with
both the enter key AND the mouse......
Can someone help me out here?
Thanks!
If this is inside a form where the action is specified as where you
really want the # to be, what happens if you change <imgto <input
type="image">?- Hide quoted text -
- Show quoted text -
If I change it to type = image, and no go. *IE only performs the MySQL
update on the first time. *And, although I've put echo statements in
the code and it looks like everything is updating, the actual values
in the database are never changed. *I even do a COUNT(*) afterwards to
check and echo that result, and it says it changed, but never any
changes occus after the first time.......totally stumped on this one.

Are you using a MySQL database or are you using one like Oracle that
requires and explicit commit?- Hide quoted text -

- Show quoted text -
I am using MySQL. After the first execution, the database record is
changed. However, after that, even though the script passes through
the code and tells me that it has been changed, and it displays the
result of the select statement which checks the record, the records
has not been changed.

If I clear the temporary files and then try again, it will work again,
for the first time only......

Jun 27 '08 #10
Mtek wrote:
On Jun 4, 3:33 pm, sheldonlg <sheldonlgwrote:
>Mtek wrote:
>>On Jun 4, 10:28 am, sheldonlg <sheldonlgwrote:
a...@unsu.com wrote:
Hi,
I have a form with an image button like this:
<td><input type='text' name='search' id='search' value=''
size=30><BR><span class=body><center>Enter Email Address</span><BR></
td>
<td><a href='#'><img src='./images/search.gif' border=0
onclick='return getCustomer(search.email.value);'></a><BR><BR></td>
Problem is that the mouse click works fine. The enter key, once you
enter data and hit enter, nothing happens. I want it to work with
both the enter key AND the mouse......
Can someone help me out here?
Thanks!
If this is inside a form where the action is specified as where you
really want the # to be, what happens if you change <imgto <input
type="image">?- Hide quoted text -
- Show quoted text -
If I change it to type = image, and no go. IE only performs the MySQL
update on the first time. And, although I've put echo statements in
the code and it looks like everything is updating, the actual values
in the database are never changed. I even do a COUNT(*) afterwards to
check and echo that result, and it says it changed, but never any
changes occus after the first time.......totally stumped on this one.
Are you using a MySQL database or are you using one like Oracle that
requires and explicit commit?- Hide quoted text -

- Show quoted text -

I am using MySQL. After the first execution, the database record is
changed. However, after that, even though the script passes through
the code and tells me that it has been changed, and it displays the
result of the select statement which checks the record, the records
has not been changed.

If I clear the temporary files and then try again, it will work again,
for the first time only......
How about a URL?
Jun 27 '08 #11

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

Similar topics

3
by: wardy1975 | last post by:
Hi all....looking for a bit of help here....I'm using an asp.net server side button, and trying to add an onclick event on the button to call a javascript function. However, I am trying to enter...
4
by: sameergn | last post by:
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...
1
by: ramalingam | last post by:
Hi I am very new to PHP. Please help. I have a HTML code in a php file which takes in USERID and password. I have <input name="Submit" type="button" value="Submit" onClick="funCheck()"/>,...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
1
by: Big George | last post by:
Hello, Controls on webpage: - Datagrid - TextBox Datagrid has Delete button: <asp:TemplateColumn HeaderText="Borrar"> <HeaderStyle Width="10%"></HeaderStyle>
1
by: mevima | last post by:
I have a small form page, with a submit button and an onclick event. <input type="button" value="Sign Up!" onClick="signUp();"> This worked just fine until I added a new regex function, but...
3
by: Jake Barnes | last post by:
I'm researching the Enter key. This is for an Ajax chat application. The designer tells me that she wants people to be able to submit text simply by hitting the Enter key. She wants this to happen...
3
by: lewnussi | last post by:
I am trying to call more than one function starting with onclick in a form to work in all browsers. In the form, this calls only function_1: <input type="submit" value="thevalue"...
3
by: Dreea | last post by:
Hello I have designed a control that consists of a textarea and a button. When the user writes text in the textarea and the Enter key is pressed then the onClick event of the button is triggered....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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,...

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.