/    Sign up×
Community /Pin to ProfileBookmark

asp + javascript:gotopage

Having problems w/ JavaScript I created. Works fine up until you get to 10, 20, and 30 so on. Any assistance would be greatly appreciated

function GetGotoPageUrlString (nPageNumber,sUrlText)
{
return “<a href=’JavaScript:GotoPage(” + nPageNumber + “);’ style=’TEXT-DECORATION: none;’>” + sUrlText
+ “</a>”;
}

function WritePagination(mypage,maxpages)
{
if (maxpages > 1 && mypage <= maxpages)
{

var str = “?euA? “;
strObj = new String(str);
var i=0;
for (i=0; i<strObj.length; ++i)
document.write(String.fromCharCode(strObj.charCodeAt(i)-3));

var counterstart = mypage – (202-i);
if (mypage%10) counterstart = mypage – (mypage%10) + 1;

var counterend = counterstart + 9;
if (counterend > maxpages) counterend = maxpages;

if (counterstart != 1)
document.write(“border=’0′><tr valign=’center’><td align=’center’>” + GetGotoPageUrlString(1,”First”)+”&nbsp;:&nbsp;”+GetGotoPageUrlString(counterstart – 1,”Previous”)+”&nbsp;<b>[</b>”);

var pad=””;
var counter = counterstart;
for(;counter<=counterend;counter++)
{
if (counter != mypage) document.write(“&nbsp;” + GetGotoPageUrlString(counter,pad + counter));
else document.write(“&nbsp;<b>” + pad + counter + “</b>”);
}
document.write(“&nbsp;<b>]</b>”);
if (counterend != maxpages) document.write(“&nbsp;” + GetGotoPageUrlString (counterend + 1,”Next”) + “&nbsp;:&nbsp;” + GetGotoPageUrlString(maxpages,”Last”))

document.write(“</td></tr></table>”);
}

}

function WritePaginationHeader(mypage,maxpages,recordCount)
{
document.write(“<table border=’0′ width=’100%’><tr valign=’center’><td align=’left’>”);
document.write(“<a href=edit.asp onClick=”javascript: document.forms.editform.action.value = ‘add’; document.forms.editform.pagenumber.value=” + mypage + “; document.forms.editform.submit(); return false;” >Add new</a>”);
document.write(“</td><td align=right>”);
document.write(“Details found: ” + recordCount + “<br>Page ” + mypage + ” of ” + maxpages);
document.write(“</td></tr></table>”);
}

Thanks,
Noel

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@buntineJul 13.2004 — Wrong forum. I will move this to the JavaScript forum for you.
Copy linkTweet thisAlerts:
@buntineJul 13.2004 — <i>
</i>function WritePagination(mypage,maxpages)
{
if (maxpages &gt; 1 &amp;&amp; mypage &lt;= maxpages)
{

Aslo, this function has an if statement, which doesnt executer any code regardless of the outcome.

Regards.
Copy linkTweet thisAlerts:
@npeaseauthorJul 13.2004 — Unfortunately the problem does not appear to be wit ht eh if statement, it seems to start with this variable string.

var str = "?euA? "; <----- this string

Thanks,

Noel
Copy linkTweet thisAlerts:
@npeaseauthorJul 14.2004 — Just in case anyone wanted to know I was able to resolve the problem. Seems there was an (%220) or something, this was causing the intervals of 10, 20, and 30 to show incorrect data, I resolved this by removing that var instance and the instance in if then. by change value to +1. Was able to move the page forward w/o all the extra false numbers.

function GetGotoPageUrlString (nPageNumber,sUrlText)

{

return "<a href='JavaScript:GotoPage(" + nPageNumber + ");' style='TEXT-DECORATION: none;'>" + sUrlText

+ "</a>";

}

function WritePagination(mypage,maxpages)

{

if (maxpages > 1 && mypage <= maxpages)

{

var str = "?eu?";
strObj = new String(str);
var i=0;
for (i=0; i<strObj.length; ++i)
document.write(String.fromCharCode(strObj.charCodeAt(i)-3));

var counterstart = mypage; <--- removed from this value
if (mypage%10) counterstart = mypage - (mypage%10) + 1; <--- this value

var counterend = counterstart + 9;
if (counterend > maxpages) counterend = maxpages;

if (counterstart != 1)
document.write("border='0'><tr valign='center'><td align='center'>" + GetGotoPageUrlString(1,"First")+"&nbsp;:&nbsp;"+GetGotoPageUrlString(counterstart - 1,"Previous")+"&nbsp;<b>[</b>");

var pad="";
var counter = counterstart;
for(;counter<=counterend;counter++)
{
if (counter != mypage) document.write("&nbsp;" + GetGotoPageUrlString(counter,pad + counter));
else document.write("&nbsp;<b>" + pad + counter + "</b>");
}
document.write("&nbsp;<b>]</b>");
if (counterend != maxpages) document.write("&nbsp;" + GetGotoPageUrlString (counterend + 1,"Next") + "&nbsp;:&nbsp;" + GetGotoPageUrlString(maxpages,"Last"))

document.write("</td></tr></table>");
}

}
×

Success!

Help @npease spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...