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
Asked
Active
Viewed 502 times
-2
-
Jac890Com10 still wont be an unique id – karthick Jun 02 '17 at 22:00
-
Please show your code. – Scott Marcus Jun 02 '17 at 22:04
1 Answers
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
-
In your_url i write submit.php page. What can i write in submit.php page – Susant Jun 02 '17 at 22:18
-
You need to put your logic there to generate roll number and send it back as response – Mir Adnan Jun 02 '17 at 23:30