How to force an Ajax Event

I have a form for data entry
The user has to enter data. But one particular field is a sequential number. This value is unique to a particular category. For example taking a school and classes I want to store the data of students class wise. For Example : Class 1 there are 20 students and for Class 2 30 students. In each class the roll number starts from 1 till the class strength so for class 1 the roll number will start with 1 and end with 20 and for class 2 it starts with 1 and ends with 30. Now I want to facilitate data entry of class wise student data for eg. Class , Student Name and Roll No. In order to enforce integrity, I want to generate roll numbers using custom logic. So the data entry operator can see the form with following structure : Class : Value is using Select (Class 1 or Class 2) . So by default the Form will show the select object as Class 1. I want to write a function in the OnBlur Event (or Click Event) such that it will find the last generated ROLL Number , add 1 to it and Show the new Roll Number for the student getting added. Now the problem is : What if the user does not select and leaves the default Class 1. Then how to generate the Roll Number ?I tried to put an ajax event
On Change === Works
On Blur = Does not Work (The field is select type dropdown ) I tried moving away from the field using Mouse as well as keyboard tab
On Click = Does not Work
On Focus = Does not Work
But this works if the field is Text Type without Select
So how to address this ? I wanted to generate the next Roll Number when the Class Gets focus
Copy paste of the code below

/**

  • Display a message after an AJAX call
    */

// Javascript message parameters
$javascript_title = ‘My Message’; // Javascript message title
$javascript_message = 'This is a test message. ’ .{pClassNumber} ; // Javascript message contents

// Display javascript message
sc_ajax_message($javascript_message, $javascript_title);