Jump to content

Recommended Posts

if(editTblRow==null && editTblCell==null){
if(fieldtype!='blob'){
$($('#ajaxtb')[0].rows[rowid].cells[cellid]).html('<input type="text" id="edit_box" class=\"edit_input\" value=\"' + id + '\" /><div class=\"cell_opts\"><a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','save','','" + updatestring + "');" + '\">Save</a> - <a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','cancel');" + '\">Cancel</a></div>'); 
} else {
$($('#ajaxtb')[0].rows[rowid].cells[cellid]).html('<textarea id="edit_box" class=\"edit_input\" value=\"' + id + '\" >' + id + '</textarea> <div class=\"cell_opts\"><a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','save','','" + updatestring + "');" + '\">Save</a> - <a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','cancel');" + '\">Cancel</a></div>');
}

The following code submits data in the input field of an ajax table on the click of the save button but I would like to change it to update on the enter key how can I change the code to do this?

 

Any help would be appreciated.

 

Regards

Luke

Link to comment
https://forums.phpfreaks.com/topic/286311-ajax-on-enter-rather-than-on-click/
Share on other sites

When you hit enter whilst entering text in an input field in a form, that form will submit..

 

The input field needs to be surround by a <form> for this to work.

 

If you don't have <form> tags around your input, then you can use this code that I found from a Google search at stackoverflow:

$(document).keypress(function(e) {
  if(e.which == 13) {
    alert('You pressed enter!');
  }
});

And put into practice here: http://jsfiddle.net/Gehtf/1/

 

Hope that helps

Denno

Edited by denno020
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.