|
 |
access_asp thread: setting selectedIndex in combo box after populating
Message #1 by "Amanda Mobberley" <amandamobberley@h...> on Mon, 21 Jan 2002 12:34:58
|
|
Can anyone please help on this (simple I am sure) problem?
I have populated a combo box with page numbers for navigation. Now I need
to set the selected page number to equal the page the user is on.
I hold the current page number in a variable called currentPage. Now I
need to use this to select the right option in the combo box.
Here is the code:
===========================================================================
<form action = "list.asp" method = "post" id=form1 name=form1>
Go to page: <select name = "goTo" size = "1">
<%
for j = 1 to objRS.PageCount
Response.Write "<option value="""&j&""">"&j&"</option>"
next
form1.goTo.options(form1.goTo.selectedIndex).value = currentPage
%>
</select> <input type = "submit" name = "goButton" value = " Go ">
===========================================================================
This doesn't change the page number, and also means the "Go" button isn't
displayed.
Or this:
===========================================================================
<form action = "list.asp" method = "post" id=form1 name=form1>
Go to page: <select name = "goTo" size = "1">
<%
for j = 1 to objRS.PageCount
Response.Write "<option value="""&j&""">"&j&"</option>"
next
%>
</select> <input type = "submit" name = "goButton" value = " Go ">
<%form1.goTo.options(form1.goTo.selectedIndex).value = currentPage%>
===========================================================================
Results in an "object required" error.
Any help would be greatly apreciated.
Message #2 by "Amanda Mobberley" <amandamobberley@h...> on Mon, 21 Jan 2002 12:56:48
|
|
Well, panic over - I've solved my own problem..!
It's:
<script language="javaScript">
document.form1.goTo.selectedIndex = (<%=currentPage%>-1);
</script>
Is this possible in VBScript..?
|
|
 |