Hi..
I am doing an online quiz software.I have total 100 questions with 5 in each page.I want to go to a particular question number and I want to fix the focus on that question(Not on the top of the page).Each question is inside a label.I am calling a function for that.I used following code.
function goto_quest(qid,cid)
{
var serial=$('#gotq').val();
var total_quest=$('#total_quest').val();
var perpage=$('#perpage').val();
$(document).ready(function()
{
$.post("gotopage.php", {serial:serial,cid:cid,perpage:perpage,total_quest:total_quest},function(data)
{
var serial1=parseInt(serial)-1;
var lid="lab"+serial1;
window.location = "example.php?page="+data;
alert(lid);
document.getElementById(lid).scrollIntoView();
document.getElementById("gotq").selectedIndex=serial1;
});
});
}
The script working fine if I use an alert on line number 19.If I comment the alert focus is not working