Focus not working. What is the error in my code
Dynamic Textbox Code:

select query
$i =1;
while()
{
<input type="text" name="class_teacher_entry[]" id="class_teacher_entry<?php echo $i; ?>" class='marks' size="5"  maxlength="3" onkeypress="return onlyNumbers(event);" onblur="markValidation(this.value,document.getElementById('marktotal').value,<?php echo $i; ?>);"/>
}


<Script>
function markValidation(a,b,i)
{
var c = parseInt(a); var d = parseInt(b);
if(c>d)
{
alert("Mark Should be less than Total marks:"+d);
document.getElementById('class_teacher_entry'+i).value='';
document.getElementById('class_teacher_entry'+i).focus();
return false;
}
}
</Script> 

No errors in your console log? Or is c never greater than d (the onblur is firing but your output never happens)?

In my code, c is always less than d. But why it is not working?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.