Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 24th, 2012, 12:16 PM
Friend of Wrox
Points: 1,007, Level: 12
Points: 1,007, Level: 12 Points: 1,007, Level: 12 Points: 1,007, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 195
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default onClick Passing parameters

I have a table with several records. The user clicks on one of the records and passes the information to another asp page. I am not sure if I am passing the record correctly. Some might offer a an HREF but I can't seem to get it to work so I went with onClick but then it's not doing anything. Here is my code, maybe someone can see what I am doing wrong. Thanks in advance...

Code:
do while not oRSMem.EOF
  Response.Write "<CENTER>"
 Response.Write _
 "<TABLE BORDER=""1"" CELLSPACING=""3"" CELLPADDING=""3"" WIDTH=""90%"">" & _
 "   <TR onmouseover=""ChangeColor(this, true);"" onmouseout=""ChangeColor(this, false);"" onClick=""window.location.replace('Directory_Display.asp?Estimate=""oRSMem(""SSN"")""');"">" & _
  "<TD>" & "<b>" & oRSMem("FamilyName") &"</TD>" & "</b>"  & _
  "<TD>" & "<b>" & oRSMem("GivenName") & "</TD>" & "</b>"  & _
  "<TD>" & "<b>" & oRSMem("SSN") & "</TD>" & "</b>"
 Response.Write "</TR>"
 
    Response.Write "</TABLE>"
  Response.Write "</CENTER>"
  oRSMem.MoveNext
  Loop
Reply With Quote
  #2 (permalink)  
Old April 24th, 2012, 02:21 PM
Imar's Avatar
Wrox Author
Points: 67,271, Level: 100
Points: 67,271, Level: 100 Points: 67,271, Level: 100 Points: 67,271, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,227
Thanks: 66
Thanked 1,414 Times in 1,394 Posts
Default

Take a look at this:

Code:
 
onClick=""window.location.replace('Directory_Display.asp?Estimate=""oRSMem(""SSN"")""');"">" & _
You're not adding the value of the record set, but embedding its name as a literl. Try this:

Code:
onClick=""window.location.replace('Directory_Display.asp?Estimate=""" & oRSMem("SSN") & """');"">" & _
or

Code:
href=""Directory_Display.asp?Estimate=" & oRSMem("SSN") & """>" & _
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old April 24th, 2012, 03:09 PM
Friend of Wrox
Points: 1,007, Level: 12
Points: 1,007, Level: 12 Points: 1,007, Level: 12 Points: 1,007, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 195
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi Imar, thanks for giving me options. Both codes were not doing anything but after revising the code. This is what I have come up and it worked.

onclick="window.location.replace('Directory_Redire ct.asp?Estimate=<%=oRSMem("SSN")%>');">

Here's another issue. After making it work, I realized that it's passing a sensitive information and displaying it in the URL. Is there a way to hide the parameter which in this case, the SSN so it won't he intercepted?

Thanks.
Reply With Quote
  #4 (permalink)  
Old April 24th, 2012, 05:13 PM
Imar's Avatar
Wrox Author
Points: 67,271, Level: 100
Points: 67,271, Level: 100 Points: 67,271, Level: 100 Points: 67,271, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,227
Thanks: 66
Thanked 1,414 Times in 1,394 Posts
Default

Oh, yes, that makes perfect sense. Forgot that; sorry.....

Quote:
Is there a way to hide the parameter which in this case, the SSN so it won't he intercepted?
Not really. You are outputting it in the wild, so it can be seen. You could protected the site with SSL to make the data less readily available.

A few alternatives:

1. Pass around another unique key

2. Store the data in a session variable and redirect

3. Encrpt the data before you append it to the query string.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #5 (permalink)  
Old April 25th, 2012, 04:34 AM
Authorized User
Points: 448, Level: 7
Points: 448, Level: 7 Points: 448, Level: 7 Points: 448, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 85
Thanks: 1
Thanked 12 Times in 12 Posts
Default

Just wanted to add one option to Imar's list:

4. submit a hidden form with javascripts
Reply With Quote
  #6 (permalink)  
Old April 25th, 2012, 08:35 AM
Friend of Wrox
Points: 1,007, Level: 12
Points: 1,007, Level: 12 Points: 1,007, Level: 12 Points: 1,007, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 195
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Can you please direct me to a link or give me a sample of a hidden form?
I went with Imar's second suggestion but would be curious to see how a hidden form works.

Thanks to both of you.
Reply With Quote
  #7 (permalink)  
Old April 25th, 2012, 09:12 AM
Authorized User
Points: 448, Level: 7
Points: 448, Level: 7 Points: 448, Level: 7 Points: 448, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 85
Thanks: 1
Thanked 12 Times in 12 Posts
Default

Hi,

something like this should work:

Code:
<html>
<head>
<script language="javascript">
	function passParamsByForm(prmName,prmVal)
	{
		document.hForm.paramName.value = prmName;
		document.hForm.paramValue.value = prmVal;
		document.hForm.submit();
	}
</script>
</head>
<body>
<form name="hForm" action="Directory_Display.asp" method="post">
	<input type="hidden" name="paramName" value="0" />
	<input type="hidden" name="paramValue" value="0" />
</form>
<a href="javascript:passParamsByForm('Estimate',12)">SSN</a>
</body>
</html>
Reply With Quote
  #8 (permalink)  
Old May 1st, 2012, 11:54 AM
Friend of Wrox
Points: 1,007, Level: 12
Points: 1,007, Level: 12 Points: 1,007, Level: 12 Points: 1,007, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 195
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Thanks disel, this helped a lot. It gave me an idea on how to go about coding it.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameters fizzerchris Access VBA 5 August 31st, 2007 12:16 PM
Passing parameters tal Ajax 5 May 26th, 2007 08:07 AM
Passing parameters ceema Crystal Reports 0 February 15th, 2006 03:03 AM
Passing Parameters spraveens Javascript 5 October 8th, 2003 07:06 AM
passing parameters spraveens Javascript How-To 1 October 8th, 2003 03:14 AM



All times are GMT -4. The time now is 05:27 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.