napsternapster Posted July 14, 2009 Share Posted July 14, 2009 Hi ppl, I have a problem with javascript events. I have created 2 functions with different purposes //function one called onkeypress function tabBackorFront() { //this function works on checks for tab key and shift if(tab == 9 && shift == false) { shows the next input text or select drop down; sets the focus on the next input text or select drop down; } else if(tab == 9 && shift == true) { sets the focus to the previous select dropdown or input text } } //function two is called onblur of an input text or onchange of a select dropdown function ShowNext() { //shows the next input text or select drop down } //this events are attached as follows to input text and drop down //input text <input type='text' oblur='javascript:ShowNext()' onkeypress=' javascript:tabBackorFront() /> //on select dropdown onkeypress='javascript:tabBackorFront' onchange='javascript:tabBackorFront() I need a way of determineing which function must be called depending on which event dat has been envoked. I thank you in advice Quote Link to comment https://forums.phpfreaks.com/topic/165913-oblur-onchange-and-onkeypress/ Share on other sites More sharing options...
Adam Posted July 14, 2009 Share Posted July 14, 2009 Look into the JS 'event' object, specifically 'event.type'. Quote Link to comment https://forums.phpfreaks.com/topic/165913-oblur-onchange-and-onkeypress/#findComment-875196 Share on other sites More sharing options...
napsternapster Posted July 15, 2009 Author Share Posted July 15, 2009 When the onkeypress event is invoked and oblur is invoked on the input text after the onkeypress event.Same as the onchange and onkeypress. 2 of these events they call the same function one after are another. function selectOption(text,current,next,previous,contact_type,detailed_type,e) { current = document.getElementById(current); next = document.getElementById(next); previous = document.getElementById(previous); if((e.keyCode == 9 && e.shiftKey == true) || (e.keyCode == 9 && e.shiftKey == false) ) { Code = e.keyCode; bool = e.shiftKey; tabBackorFront(text,current,next,previous,contact_type,detailed_type); } else { ShowNext(text,current,next,previous,contact_type,detailed_type); } } Quote Link to comment https://forums.phpfreaks.com/topic/165913-oblur-onchange-and-onkeypress/#findComment-875753 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.