Click to See Complete Forum and Search --> : Move next


TLMM
08-27-2003, 10:19 AM
I am creating a web site that has several sections. Some sections were long, so I created next and previous buttons to move to the next part of the section. This is all done on the same page and I use case statements to determine which text appears when the next or previous is clicked. It works prefect in IE, but I just tried it in Netscape 7.1 and it won't work. It will not move to the next page. Below is an example of my code. It anyone can help, it would be greatly appreciated. I have to have this completed in the next week. Thanks.

These are the next and previous functions:

<SCRIPT LANGUAGE="javascript">

<!--

//Move Previous

function OnMovePrevious()

{

var lngAbsolutePosition


if (document.all["txtHiddenImpactPageNum"].value=="1")

{

return false;

}

lngAbsolutePosition=(document.all["txtHiddenImpactPageNum"].value * 1) - 1;


//Set the hidden textbox to pass across on the submit of the page

document.all["txtHiddenImpactPageNum"].value = lngAbsolutePosition;


//********Change the form name here if you change it in the form tag.******************

document.all["frmImpact"].submit();


return false;

}

//Move Next

function OnMoveNext()

{

var lngAbsolutePosition


// ******** IMPORTANT: YOU MUST SET THE LAST PAGE HERE INTO THE lngLastPage VARIABLE. ******************

var lngLastPage = "2";

lngAbsolutePosition=(document.all["txtHiddenImpactPageNum"].value * 1) + 1;

if (lngAbsolutePosition > (lngLastPage * 1))

{

return false;

}


document.all["txtHiddenImpactPageNum"].value = lngAbsolutePosition;


//********Change the form name here if you change it in the form tag.******************

document.all["frmImpact"].submit();

return false;

}


This is the code to set the variable:


<%@ Language=VBScript %>

<%Option Explicit%>

<%

Dim strImpactPageNum

strImpactPageNum = Request.Form("txtHiddenImpactPageNum")

'If this page is not submitting to itself, then it must be the first page

if IsEmpty(strImpactPageNum) then

strImpactPageNum = 1

end if

%>


This is sample code from one of the case statements:


<%Select Case UCASE(strImpactPageNum) 'Checking to see which page to build%>


<%Case 1 'Build Page 1 %> CODE........

<form name="frmImpact" action="Impact.asp" method="Post">

<font face="Tahoma" size="1" color="#000000"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1</b></font>&nbsp;&nbsp;&nbsp;

<font face="Tahoma" size="1" color="#C85E00"><b>2</b></font>


<%

Dim a

For a = 1 to 23

%>

&nbsp;

<%

next

%>


<a href onclick="return OnMoveNext()" style="text-decoration: none"><font face="Tahoma" size="1" color="#C85E00"><b>next&nbsp;

&gt; &gt;</b></font></a>


<!--Create a hidden textbox to hold the value of the page-->

<input type="hidden" name="txtHiddenImpactPageNum" value="<%=strImpactPageNum%>">

</form>

Other cases...

<%End Select%>

Thanks in advance to anyone who can help.

Khalid Ali
08-27-2003, 10:38 AM
the very first thing that I notice is this

document.all[

its IE specifc code and how do u expect it to work in NS??? :D

if there aren't any other issues with your code
then replace all instances of this

document.all[

with
document.getElementById(

make sure you use parenthesis do not use square brackets

TLMM
08-27-2003, 12:40 PM
Thanks very much for responding. I tried the code though an dcouldn't get it to work. I changed my code to the following and this works:

<SCRIPT LANGUAGE="javascript">
<!--
//Move Previous
function OnMovePrevious()
{
var lngAbsolutePosition

//if (document.all("txtHiddenDisastersSubPageNum").value=="1")
if (window.document.frmDisastersSub.txtHiddenDisastersSubPageNum.value=="1")
{
return false;
}
//lngAbsolutePosition=(document.all("txtHiddenDisastersSubPageNum").value * 1) - 1;
lngAbsolutePosition=(window.document.frmDisastersSub.txtHiddenDisastersSubPageNum.value * 1) - 1;

//Set the hidden textbox to pass across on the submit of the page
//document.all("txtHiddenDisastersSubPageNum").value = lngAbsolutePosition;
window.document.frmDisastersSub.txtHiddenDisastersSubPageNum.value = lngAbsolutePosition;

//********Change the form name here if you change it in the form tag.******************
//document.all("frmDisastersSub").submit();
window.document.frmDisastersSub.submit();

return false;
}
//Move Next
function OnMoveNext()
{
var lngAbsolutePosition

// ******** IMPORTANT: YOU MUST SET THE LAST PAGE HERE INTO THE lngLastPage VARIABLE. ******************
var lngLastPage = "2";

//lngAbsolutePosition=(document.all("txtHiddenDisastersSubPageNum").value * 1) + 1;
lngAbsolutePosition=(window.document.frmDisastersSub.txtHiddenDisastersSubPageNum.value * 1) + 1;

if (lngAbsolutePosition > (lngLastPage * 1))
{
return false;
}

//document.all("txtHiddenDisastersSubPageNum").value = lngAbsolutePosition;
window.document.frmDisastersSub.txtHiddenDisastersSubPageNum.value = lngAbsolutePosition;

//********Change the form name here if you change it in the form tag.******************
//document.all("frmDisastersSub").submit();
window.document.frmDisastersSub.submit();
return false;
}

function OpenDisastersSubPics(strName)
{

// Where to open this window - Calculate screen size
var lngWidth = (window.screen.width * 1);
var lngHeight = (window.screen.height * 1);
var lngTop = ((lngHeight - 450) / 2); //Used to contain the top position of the form to be displayed
var lngLeft = ((lngWidth - 450) / 2); //Used to contain the Left position of the form to be displayed

switch(strName)
{
case 'DisastersSubPic1':
var strWindow=window.open("DisastersSubPics.htm","wndOpenPage","width=450, height=450, toolbar=no, menubar=no, status=no, location=no, directories=no, resizable=no, scrollbars=auto, TOP="+lngTop+", LEFT="+lngLeft+"");
break

}

strWindow.focus();
return false;
}
-->

I am not too familiar with Netscape so I am running into problems now and then. Is there a resource or site that you use with examples of what can or can't be used in Netscape and IE?

Thanks again!

Khalid Ali
08-27-2003, 01:06 PM
browse through this site,a js resource can get better then this.

http://devedge.netscape.com/

TLMM
08-27-2003, 01:10 PM
Thanks a lot!