Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I'm not understanding why Re

Status
Not open for further replies.

DKL01

Programmer
Sep 14, 2000
233
US
Hi,

I'm not understanding why Request.Form("datasets") is not returning value "ABCD" when I click on page 2.

Thanks

************** testpage.asp *************
<HTML>
<BODY>

<FORM NAME=&quot;FORM1&quot; METHOD=&quot;POST&quot; >

<%

Dim Buffer
Buffer = Request.Form(&quot;datasets&quot;)
Response.write Buffer

Response.write &quot;Select page to view more records&quot;
For I = 1 to 10

Response.Write &quot;<A HREF=&quot;&quot;testpage.asp?PageNumber=&quot; & I & &quot;&quot;&quot; LANGUAGE=&quot;&quot;VBScript&quot;&quot; onClick=&quot;&quot;vbFunction()&quot;&quot; >&quot; & &quot; &quot; & I & &quot;</A>&quot;

Next

%>

<INPUT Type=&quot;hidden&quot; name=&quot;datasets&quot; >

</FORM>



<script language=&quot;VBScript&quot; >
sub vbFunction()
form1.datasets.value = &quot;ABCD&quot;
form1.submit
end sub
</script>

</BODY>
</HTML> [sig][/sig]
 
Try this...

Code:
default.asp -
<html>
<head>
	<script language=&quot;VBScript&quot;>
		Sub fnSubmit(pageNumber)
			frmForm.hdnDatasets.value=&quot;ABCD&quot;
			frmForm.action=&quot;testpage.asp?pagenumber=&quot; & pageNumber
			frmForm.submit					
		End Sub	
	</script>
</head>
<body>
<form id=frmForm name=frmForm method=&quot;POST&quot;>
Choose from the following pages: 
<%
for i=1 to 10
	response.write &quot;<a href='#' onClick='fnSubmit(&quot; & i & &quot;)'> &quot; & i & &quot; </a>&quot;
next
%>
	<input type=hidden id=hdnDatasets name=hdnDatasets>
</form>
</body>
</html>

testpage.asp -
<%
	Dim datasets
	datasets = request.form(&quot;hdnDatasets&quot;)
	pagenumber = request.QueryString(&quot;pagenumber&quot;)
	response.write datasets & &quot;<br>&quot;
	response.write pagenumber
%>

I believe the problem arises because of timing issues. It is better, when using the <a> tag to have the function do everything rather than half being done by the function and half being done by the tag.

Hope this helps, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
This code looks good. But when I click on page # 2 on Default.asp it is not displaying testpage.asp instead it is showing in the address space.

I'm using Windows NT and Personal Web Server.

Please help.
Thanks [sig][/sig]
 
Does it only happen on page #2? It works fine for me but I don't have the ability to verify it on PWS (I use IIS). It should work for anything. Here is the same thing in javascript (without using asp). Use it in place of the default.asp (I try to make do much as possible with client-side scripting as that takes a load off the server)...

Code:
default.html - 
<html>
<head>
	<script language=&quot;javascript&quot;>
		function fnSubmit(pageNumber){
			frmForm.hdnDatasets.value=&quot;ABCD&quot;;
			frmForm.action=&quot;testpage.asp?pagenumber=&quot; + pageNumber;
			frmForm.submit();
		}
	</script>
</head>
<body>
<form id=frmForm name=frmForm method=&quot;POST&quot;>
Choose from the following pages: 
<script language=&quot;javascript&quot;>
	for (i=1;i<=10;i++){
		document.write(&quot;<a href=\&quot;#\&quot; onClick=\&quot;fnSubmit(&quot; + i + &quot;)\&quot;> &quot; + i + &quot; </a>&quot;);
	}
</script>
	<input type=hidden id=hdnDatasets name=hdnDatasets>
</form>
</body>
</html>

Also, make sure you execute both default.asp and default.html from an http call not by simply double clicking the file.

Hope it helps, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Unfortunately, you can't (legally) download IIS. It comes with NT Server 4.0 (IIS 2 yech!) and can be upgraded to IIS 4 (much better) via the Option Pack. Windows 2000 Pro/Server comes with IIS 5 (excellent!). If you can pick up a copy of Win2K (and have the hardware to run it) you'll be much happier. I don't understand why the code won't run on PWS. Do you have your PWS set up correctly? I will setup PWS at home tonight and let you know.

Later, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
THANK U VERY MUCH.. [sig][/sig]
 
Pretty obvious once I sat down and looked at it. PWS doesn't properly interpret the href=&quot;#&quot; so use the following instead (and upgrade to IIS ASAP (no really, I mean it ;-) )...

Code:
for the default.asp example change

response.write &quot;<a href='#' onClick='fnSubmit(&quot; & i & &quot;)'> &quot; & i & &quot; </a>&quot;

to

response.write &quot;<a href='javascript:fnSubmit(&quot; & i & &quot;)'> &quot; & i & &quot; </a>&quot;

for the default.html example change

document.write(&quot;<a href=\&quot;#\&quot; onClick=\&quot;fnSubmit(&quot; + i + &quot;)\&quot;> &quot; + i + &quot; </a>&quot;);

to

document.write(&quot;<a href=\&quot;javascript:fnSubmit(&quot; + i + &quot;)\&quot;> &quot; + i + &quot; </a>&quot;);

Later,


[sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Rob,

It worked. Thank you very much....
I will move to IIS.

Dilip [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top