onClick vs Enter Key

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!
 
D

Dan Rumney

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.
 
M

Mtek

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......
 
M

Mtek

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.......
 
D

Dan Rumney

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
 
M

Mtek

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="none";
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.responseText;
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
 
M

Mtek

If this is inside a form where the action is specified as where you
really want the # to be, what happens if you change <img> to <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.
 
M

Mtek

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......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top