davidedpg10
Apprentice

Clicking a button When the Enter key is pressed on a particular textbox

Jump to solution

I have a textbox used to search a list view.  However by default hitting Enter on a textbox does nothing.

I need to click an existing button when people hit enter while on that search textbox.
I tried this JS

<script> $('[name="Search Box"]').keyup(function(event) { if (event.keyCode == 13) { $('[name="Refresh"]').click(); } }); </script>

("Search Box" being the name of the textbox, and Refresh being the name of the button, however I have tried it several times and the button does not get clicked when I hit enter. I have also tried .keypress instead of .keyup and neither work. The Data label is set to literal)

 

I know this has been asked before but the above was the solution, and it is not working for me.
Running K2 4.7

Thanks

0 Kudos
3 Replies
Not applicable

Re: Clicking a button When the Enter key is pressed on a particular textbox

Jump to solution
Hi David,

 

Did you make sure afer adding the script as an expression on a datalabel the literal property on the data label is selected.

From there, it will  be able to call the datalabel anywhere in your rule structure for example:
When text box has changed
Then call the datalabel to execute the script

 

 
davidedpg10
Apprentice

Re: Clicking a button When the Enter key is pressed on a particular textbox

Jump to solution

Yes, The datalabel is literal and not visible.

It is not executing though, or at least not clicking the button when I hit enter while typing in the textbox.
I have no idea why. It should work.

0 Kudos
davidedpg10
Apprentice

Re: Clicking a button When the Enter key is pressed on a particular textbox

Jump to solution
My bad, it was the button name that was wrong..
It was "Refresh_Button" not "Refresh"
0 Kudos