Hey all!

Ok, right to the point here!

I have a page in ASP.NET which has two sets of username and password boxes
and two sets of submit buttons. Because it is ASP.NET, there can only be one
form in a page.

The problem in a normal page is that, when the user presses enter on the
keyboard, the first submit control is triggered. What if someone enters info
in the second username and password boxes? Well, the page simply doesn't
know which control the user was in when they hit enter.

So... I wrote something which determines which textbox the user was in when
they pressed enter (keycode 13)

$(document).ready(function(){
  $("#ctl00_contentPlc_txtPassword").keydown(function(){
    //The user pressed a key in the password textarea
    if ((event.which && event.which == 13) || (event.keyCode &&
event.keyCode == 13))
    {
      //The user pressed enter. Check if the relevant textboxes are filled
correctly. If not, show the error and return false
      if (!CheckLogin())
        return false;
      else
        //User has filled in the textboxes properly. Now simulate a click on
the first button.
        $("#ctl00_contentPlc_btnCheck").click();
    }
  });

  $("#ctl00_contentPlc_txtOtherPassword").keydown(function(){
    //The user pressed a key in the password textarea
    if ((event.which && event.which == 13) || (event.keyCode &&
event.keyCode == 13))
    {
      //The user pressed enter. Check if the relevant textboxes are filled
correctly. If not, show the error and return false
      if (!CheckOtherLogin())
        return false;
      else
        //User has filled in the textboxes properly. Now simulate a click on
the first button.
        $("#ctl00_contentPlc_btnOtherCheck").click();
    }
  });
});

There is a problem however. The script works, but doesn't actually simulate
a click on the second button. If I replace
$("#ctl00_contentPlc_btnOtherCheck").click(); with alert("hello");, I'll get
a lovely message come up when I press enter in the second password textarea.
So this indicates to me that the script is working ok, but the button isn't
being fired. The button exists and I can reference it, but I simply can't
fire it.

I've also tried $("[EMAIL PROTECTED]").get(1).click(); but this doesn't
work either (note, that the button is an image button).

Is there anyone who has had a similar problem and solved it?

Cheers,

Dan
-- 
View this message in context: 
http://www.nabble.com/Determine-which-button-was-just-clicked-tf2298484.html#a6386343
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to