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(); 

$.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;



The script working fine if I use an alert on line number 19.If I comment the alert focus is not working

I am a little confused on what your are trying to do but in order to set the focus of an input element given the id for that input you would use something like

Be a part of the DaniWeb community

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