By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,012 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

onClick vs Enter Key

P: n/a
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
Share this Question
Share on Google+
10 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.