Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2005, 01:12 AM
Registered User
 
Join Date: Nov 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Submitting a form via a link with variables

I am trying to submit a form via a link. I am passing some variables. When I submit the form the variables are not posted. When I do a Response.Querystring("orderid"), it returns no value i.e. blank.

Attached is my code:
<a href=purchase.asp?orderid=123 onclick='document.myform.submit();return false;'>Link </a>

How can I submit a form via a link and pass through some variables at the same time.

I cannot use input text = hidden for this purpose. I have to pass through the values via a QueryString.

thanks
Calvin
 
Old November 3rd, 2005, 03:54 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

The QS is part of the Request object, you should use:
Request.Querystring("orderid")

What method are you using in your <form...> tag?
If your wany to send variables as QueryStrings <form method="get">
To send them as form variables <form method="post"> To get values:
Request.form("orderid")

IMO use Post unless for some strange reason you cant

Wind is your friend
Matt
 
Old November 3rd, 2005, 11:00 AM
Registered User
 
Join Date: Nov 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

MAtt,
Thanks for your response.

Sorry, I was using Request.Querystring but that returns nothing.

I cannot pass a form variable. I have to pass this variable via a Querystring, via a link - however if I include the onclick submit in the href string, it does not seem to pass on the variables.

Thanks
Cassandra

 
Old November 3rd, 2005, 06:05 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

What is your syntax for this? Something like:
onClick="Javascript:formName.submit();"

If you are using method="get" you dhould see your values in the address bar on the destinatio page, do you?

Wind is your friend
Matt
 
Old November 4th, 2005, 02:24 AM
Registered User
 
Join Date: Nov 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My syntax is:
<a href=purchase.asp?orderid=123 onclick='document.myform.submit();return false;'>Order ID </a>

I am generating a SQL query that lists all the orders in the ORDERS table. If a user clicks on the link of a partiular record (Order) then it takes them to a page that details all the information about the Order. Via the link I am passing on the 'Order ID' variable. I am also submitting a whole lot of information as hidden form variables. If I use method="get" I will end up with a lot of querystrings in the header, which I do not want.

Sorry, I am a newbie at this, so I hope I'm explaining this correctly.

 
Old November 6th, 2005, 06:33 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

you said:
.;;;I cannot pass a form variable. I have to pass this variable via a Querystring,

Then you said:
;;;I use method="get" I will end up with a lot of querystrings in the header, which I do not want

mmmm, why cant you pass the orderID in a form variable - hidden or passed into a JS function?

You are:
;;;I am generating a SQL query that lists all the orders in the ORDERS table

So in your loop do something like (do not place your <form> or </form> tag in the loop):

cut n paste stat (just change the record set name)------------------
<table>
<%
If not ordersRS.EoF then
   do until ordersRS.EoF %>
      <input type="hidden" name="orderIds" value="<%= ordersRS(2) %>">
      'now write your orders row
      <tR>
       <td>The orders text</td>
       <tD><a href="#" onClick="myform.submit();><img src="images/someName.gif" width="160" height="16" border="0"></a>
      </tR>
<% ordersRS.moveNext
   loop
else
   response.write "<tR><Td>No Data Found</td></tr>"
end if
%>
</table>
cut n paste finish---------------------------

Any how thats one of many ways to do it.


Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
form submitting cro_crx Pro PHP 5 January 25th, 2005 12:19 PM
Form Submitting cro_crx Beginning PHP 3 January 17th, 2005 01:30 PM
Submitting a form YuliaKupina Classic ASP Basics 3 June 24th, 2004 01:52 AM
Getting a Result WITHOUT submitting a form? Lucy Javascript How-To 4 November 18th, 2003 08:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.