views:

42

answers:

2

i think i have read every page google knows about which has these keywords, and nothing works for me.

what i have is a form input, and a button next to it [not submit], and what i want is for the button click to trigger an 'enter' key click. [this will respectively run another function which is already working..]

i've tried

<input id='inputBtn' type='button' .... onclick='$('#otherInput').trigger('keypress',[13]);' >

and also putting it in a function and then running it from onclick, or making a

$('#inputBtn').click(function().....

nothing works for me please help!!

A: 

You might need to provide some example code. I can't think of any reason you couldn't just have the second function (that runs when enter is pressed) being called by the click event on your button.

function onEnter()
{
 //Do something
}

jQuery("#inputButton").live("click",onEnter());

Should work.

danspants
i cant tell you how i laughed when i read this, since this was exactly the kind of thing i was looking for, i just there has to be another way.not a programmer, thanks pants@dan.[works perfectly, and much more elegantly]
adir
+2  A: 
$('input').trigger({
  type:  'keypress',
  which:  13
});

--EDIT--

you might want to extend that with

keyCode: 13,
charCode: 13

etc.

Kind Regards

--Andy

jAndy
do you have any link with the key numbers for me?
meo
there are lots offhttp://www.cambiaresearch.com/c4/702b8cd1-e5b0-42e6-83ac-25f0306e3e25/Javascript-Char-Codes-Key-Codes.aspx
jAndy
merci @jAndy ! what is the difference between keyCode and charCode ?
meo
for real?snippet from your profile---UI-Designer/Programmer. (Mostly HTML, JS and CSS)---
jAndy