...

View Full Version : creating an object and calling function in event handler



bakiyalakshmi
12-19-2007, 04:58 AM
Hi

I have trouble in executing the following part of code. can anyone help on it

<input type="button" value="Go" onclick="
var pager = new Pager('results',10);
pager.init();
pager.showPageNav('pager', 'pageNavPosition');
pager.showPage(1);return false;
" />

whenever i execute this code, i get an error that pager is undefined.But if i put this line "var pager = new Pager('results',10);" in a separate script then it works fine.. so please help me in this issue.

abduraooft
12-19-2007, 08:40 AM
<script type="text/javascript">
function show()
{
var pager = new Pager('results',10);
pager.init();
pager.showPageNav('pager', 'pageNavPosition');
pager.showPage(1);return false;
}
</script>


<input type="button" value="Go" onclick="show();" /> ?

bakiyalakshmi
12-19-2007, 12:22 PM
Even this i tried.. same error occurs....

Kor
12-19-2007, 12:43 PM
should pager variable be a global? In this case:


... onclick="pager=new Pager('results',10);..."

bakiyalakshmi
12-24-2007, 07:44 AM
If it is a global variable .then the logic doesnt work properly



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum