Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 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 Search this Thread Display Modes
  #1 (permalink)  
Old November 3rd, 2005, 01:12 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old November 3rd, 2005, 03:54 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #3 (permalink)  
Old November 3rd, 2005, 11:00 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old November 3rd, 2005, 06:05 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #5 (permalink)  
Old November 4th, 2005, 02:24 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
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.

Reply With Quote
  #6 (permalink)  
Old November 6th, 2005, 06:33 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
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



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


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