onClick vs Enter Key

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • art@unsu.com

    onClick vs Enter Key


    Hi,

    I have a form with an image button like this:

    <td><input type='text' name='search' id='search' value=''
    size=30><BR><sp an class=body><cen ter>Enter Email Address</span><BR></
    td>
    <td><a href='#'><img src='./images/search.gif' border=0
    onclick='return getCustomer(sea rch.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!
  • Dan Rumney

    #2
    Re: onClick vs Enter Key

    On Jun 3, 5:21 pm, "a...@unsu. com" <ame...@iwc.net wrote:
    Hi,
    >
    I have a form with an image button like this:
    >
    <td><input type='text' name='search' id='search' value=''
    size=30><BR><sp an class=body><cen ter>Enter Email Address</span><BR></
    td>
    <td><a href='#'><img src='./images/search.gif' border=0
    onclick='return getCustomer(sea rch.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.

    Comment

    • Mtek

      #3
      Re: onClick vs Enter Key

      On Jun 3, 5:48 pm, Dan Rumney <danrum...@warp mail.netwrote:
      On Jun 3, 5:21 pm, "a...@unsu. com" <ame...@iwc.net wrote:
      >
      Hi,
      >
      I have a form with an image button like this:
      >
      <td><input type='text' name='search' id='search' value=''
      size=30><BR><sp an class=body><cen ter>Enter Email Address</span><BR></
      td>
      <td><a href='#'><img src='./images/search.gif' border=0
      onclick='return getCustomer(sea rch.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......

      Comment

      • Mtek

        #4
        Re: onClick vs Enter Key

        On Jun 3, 5:48 pm, Dan Rumney <danrum...@warp mail.netwrote:
        On Jun 3, 5:21 pm, "a...@unsu. com" <ame...@iwc.net wrote:
        >
        Hi,
        >
        I have a form with an image button like this:
        >
        <td><input type='text' name='search' id='search' value=''
        size=30><BR><sp an class=body><cen ter>Enter Email Address</span><BR></
        td>
        <td><a href='#'><img src='./images/search.gif' border=0
        onclick='return getCustomer(sea rch.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(e vent.KkeyCode== 13)
        {event.keyCode= 9;getCustomer(c ustform.email.v alue);return
        false;}"><BR><s pan class=body><cen ter>Enter Email Address</span><BR></
        td>
        <td><a href='#'><img src='./images/email.gif' border=0 onclick='return
        getCustomer(cus tform.email.val ue);'></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.......


        Comment

        • Dan Rumney

          #5
          Re: onClick vs Enter Key

          On Jun 3, 9:40 pm, Mtek <m...@mtekusa.c omwrote:
          On Jun 3, 5:48 pm, Dan Rumney <danrum...@warp mail.netwrote:
          >
          >
          >
          On Jun 3, 5:21 pm, "a...@unsu. com" <ame...@iwc.net wrote:
          >
          Hi,
          >
          I have a form with an image button like this:
          >
          <td><input type='text' name='search' id='search' value=''
          size=30><BR><sp an class=body><cen ter>Enter Email Address</span><BR></
          td>
          <td><a href='#'><img src='./images/search.gif' border=0
          onclick='return getCustomer(sea rch.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(e vent.KkeyCode== 13)
          {event.keyCode= 9;getCustomer(c ustform.email.v alue);return
          false;}"><BR><s pan class=body><cen ter>Enter Email Address</span><BR></
          td>
          <td><a href='#'><img src='./images/email.gif' border=0 onclick='return
          getCustomer(cus tform.email.val ue);'></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

          Comment

          • Mtek

            #6
            Re: onClick vs Enter Key

            On Jun 3, 9:35 pm, Dan Rumney <danrum...@warp mail.netwrote:
            On Jun 3, 9:40 pm, Mtek <m...@mtekusa.c omwrote:
            >
            >
            >
            >
            >
            On Jun 3, 5:48 pm, Dan Rumney <danrum...@warp mail.netwrote:
            >
            On Jun 3, 5:21 pm, "a...@unsu. com" <ame...@iwc.net wrote:
            >
            Hi,
            >
            I have a form with an image button like this:
            >
            <td><input type='text' name='search' id='search' value=''
            size=30><BR><sp an class=body><cen ter>Enter Email Address</span><BR></
            td>
            <td><a href='#'><img src='./images/search.gif' border=0
            onclick='return getCustomer(sea rch.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(e vent.KkeyCode== 13)
            {event.keyCode= 9;getCustomer(c ustform.email.v alue);return
            false;}"><BR><s pan class=body><cen ter>Enter Email Address</span><BR></
            td>
            <td><a href='#'><img src='./images/email.gif' border=0 onclick='return
            getCustomer(cus tform.email.val ue);'></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(pem ail) {
            document.getEle mentById('inner b').style.displ ay="none";
            var strURL="./xml/custform.php?pe mail="+pemail;
            req = new XMLHttpRequest( true);
            if (req) {
            req.onreadystat echange = function() {
            if (req.readyState == 4) { // only if "OK"
            if (req.status == 200) {

            document.getEle mentById('inner b').innerHTML=r eq.responseText ;
            document.getEle mentById('inner b').style.displ ay="";
            } 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

            Comment

            • sheldonlg

              #7
              Re: onClick vs Enter Key

              art@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><sp an class=body><cen ter>Enter Email Address</span><BR></
              td>
              <td><a href='#'><img src='./images/search.gif' border=0
              onclick='return getCustomer(sea rch.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">?

              Comment

              • Mtek

                #8
                Re: onClick vs Enter Key

                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><sp an class=body><cen ter>Enter Email Address</span><BR></
                td>
                <td><a href='#'><img src='./images/search.gif' border=0
                onclick='return getCustomer(sea rch.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.......tota lly stumped on this one.



                Comment

                • sheldonlg

                  #9
                  Re: onClick vs Enter Key

                  Mtek wrote:
                  On Jun 4, 10:28 am, sheldonlg <sheldonlgwrote :
                  >a...@unsu.co m 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><cen ter>Enter Email Address</span><BR></
                  >>td>
                  >><td><a href='#'><img src='./images/search.gif' border=0
                  >>onclick='retu rn getCustomer(sea rch.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.......tota lly stumped on this one.
                  Are you using a MySQL database or are you using one like Oracle that
                  requires and explicit commit?

                  Comment

                  • Mtek

                    #10
                    Re: onClick vs Enter Key

                    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><s pan class=body><cen ter>Enter Email Address</span><BR></
                    >td>
                    ><td><a href='#'><img src='./images/search.gif' border=0
                    >onclick='retur n getCustomer(sea rch.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.......tota lly 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......

                    Comment

                    • sheldonlg

                      #11
                      Re: onClick vs Enter Key

                      Mtek wrote:
                      On Jun 4, 3:33 pm, sheldonlg <sheldonlgwrote :
                      >Mtek wrote:
                      >>On Jun 4, 10:28 am, sheldonlg <sheldonlgwrote :
                      >>>a...@unsu.co m wrote:
                      >>>>Hi,
                      >>>>I have a form with an image button like this:
                      >>>><td><inpu t type='text' name='search' id='search' value=''
                      >>>>size=30><BR ><span class=body><cen ter>Enter Email Address</span><BR></
                      >>>>td>
                      >>>><td><a href='#'><img src='./images/search.gif' border=0
                      >>>>onclick='re turn getCustomer(sea rch.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.......tota lly 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?

                      Comment

                      Working...