-2

i fill up 4 field(Name,Phone,Course,Center) in my form. 5th field is "roll". when i fill up 4 field, then how to generate roll without form submission, i want to generate roll like that My 4 field text are below Name-Jack,Phone-1234567890,Course-Computer,Center-010 after fill up this field then generate roll and print 5th field without form submission Roll-Jac890Com10

Scott Marcus
  • 64,069
  • 6
  • 49
  • 71
Susant
  • 87
  • 2
  • 9

1 Answers1

0

You could attach an onchange event to your inputs.

<form method="post" action="">
<input type="text" name="name" id="name" onchange="my_validate_func()">
<input type="text" name="phone" id="phone" onchange="my_validate_func()">
<input type="text" name="course" id="course" onchange="my_validate_func()">
<input type="text" name="center" id="center" onchange="my_validate_func()">
<input type="text" name="roll" id="roll">
<button type="submit">Submit</button>

function my_validate_func (){ 
   if($('#name').val()!="" && $('#phone').val()!="" && $('#course').val()!="" && $('#center').val()!=""){
       $.ajax({
         url:'your_url',
         success: function(response){
            $('#roll').val(response.roll_num);
         }
       });
   }
}
Mir Adnan
  • 844
  • 11
  • 24