Forum Moderators: open

Message Too Old, No Replies

transfer a value from html to asp code using onclick

html value to asp code

         

Zincoianoid

9:46 pm on Nov 24, 2003 (gmt 0)

10+ Year Member



I have a page which uses the onclick command:
<a href='#' onClick='go("products.asp");return false;'>Products</a>

I want to use multiples of it as menu choices, no problem there.
But each choice as yet only takes you to a page. I want it to choose the same page but have a variable set so that the asp code on the page can tell which choice it was and alter the query.
It is part of a simple shopping cart and using anything besides onclick seems to causes the cart to reset (another thing I have to look at).

Also, my old html book does not mention onclick. What version of code is this command and where can I find good online references to it?

in the sample below 'choose' is to get the string 'wipers' and the product.asp page needs to take the string and add it to myquery which becomes the query for what parts are to be shown.

Sample of the code, 2 files.
this is the head.asp file

<p>[&nbsp;<a href='#'
onClick='go("/index.asp");return false;'>Home</a>&nbsp;¦&nbsp;<a href='#'

onClick='go("products.asp?choose=bulbs");return false;'>bulbs</a>&nbsp;¦&nbsp;<a href='#'
onClick='go("products.asp?choose=wipers");return false;'>wipers</a>&nbsp;¦&nbsp;<a href='#'
onClick='go("products.asp?choose=oil");return false;'>oil</a>&nbsp;¦&nbsp;<a href='#'

onClick='go("cart.asp");return false;'>Show Cart</a>&nbsp;]

this is the products asp file:

<!--#include file='db.asp'-->
<!--#include file='head.asp'-->

*** notice the link to head.asp which shows this menu on the products page

<title>Auto Supplies</title>

<table border=0 width=500 cellpadding=0 cellspacing=0>
<%

' Value of text input field "choose"

myquery = Request.Form("choose")
myquery = "exec q"
if myquery = "exec q" then myquery = "exec qlistall"

' executing stored procedure

set rs = conn.execute(myquery)
do while not rs.eof

*** end of file

Any help would be welcomed.
Thanks

IanTurner

10:06 pm on Nov 24, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If you are pusing a "page.asp?choose=abc" then you should be using request.querystring("choose") rather than request.form("choose")

Zincoianoid

10:38 pm on Nov 24, 2003 (gmt 0)

10+ Year Member



Ian Turner
Someone else said the same thing.
So let me see if I got it right?

' Value of text input field "choose"
myquery = request.querystring("choose")
myquery = "exec q" & myquery
if myquery = "exec q" then myquery = "exec qlistall"

Is that right?

Yes I tried it sw where other mistakes were made and now it looks like it works.

thanks

IanTurner

10:57 pm on Nov 24, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I'm not too sure about how you have set up your SQL but in essence you are using the querystring correctly now.

You can always use

response.write myquery at strategic places to write the SQL code out to see when it is right.