naamabm Posted July 18, 2012 Share Posted July 18, 2012 On my web I display configuration info, that user can edit, in a table.The correct user behavior should be to press Enter key after editing the field in order to set the changes. If he "leaves" the field without pressing Enter- the changes will be dismiss.In order to do that- I use "onkeyup" and "onblur" "onkeyup"(1) set a flag that field's content has been changed(2) if the key is Enter (==13) , it sends the server a set request with the current value(*) also tried "onkeypress" or "onkeydown" "onblur" - check the flag if the field's content has been changed. if so- send a refresh request to server that re-send current saved data (and erase user's changes). I recently noticed that while it works great in Chrome, on Explorer pressing the Enter key sets both events, and sometimes only the "onblur" event, thus ignores user's requests.... Do you have any idea how to deal with it? THANKS!!!! Link to comment Share on other sites More sharing options...
justsomeguy Posted July 18, 2012 Share Posted July 18, 2012 The key event should fire first, so you can use that event to set a flag that the field was just updated. In the blur event you can check for that flag and if it's set then don't do anything. Link to comment Share on other sites More sharing options...
naamabm Posted July 29, 2012 Author Share Posted July 29, 2012 That is exactly what I do, and it seems that onBlur is the first:set_is_unsaved_change() ...... <!-- Line LO freq --><tr><td><div id=div_lof_a><a href="manual.html#lof_mod" target="_blank">BUC LO Freq</a></div></td><td><div id=div_lof_select><input id="lof" value="" onkeyup="set_is_unsaved_change();if ((event.keyCode==13) && (div_img_no_touch.className=='no_touch_hide') && (is_positive_num(this))) {div_img_long_action.className='wait_img_show';div_img_no_touch.className='no_touch_show';updateStatusParams('query.fcgi','form_state=2&form_name=line_mod&field_name=lof&field_val='+this.value);reset_is_unsaved_change();}" onblur="if(is_set_unsaved_change()) {reset_is_unsaved_change();updateStatusParams('query.fcgi','form_state=1&form_name=line_mod');}"></div></td></tr>............... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now