Click to See Complete Forum and Search --> : Asp Faq


jjr0319
01-10-2006, 11:24 AM
i have a FAQ page created in ASP. the questions/answers are stored in microsoft access. on the main faq page is a listing of just the questions, which get called from the DB by a simple SELECT statement:

strSQL = strSQL & "SELECT * FROM FAQ ORDER BY FAQ.[DATE]DESC, FAQ.[QUESTION]"

i want to hyperlink these questions, so that when clicked, the question and it's answer will be in a popup box. right now, i just have the link setup as a .htm file, in which i have to manually code the question and answer. this is the hyperlink i have setup now (answeb field contains the name of the .htm page):

<a href="#" onclick="javascript:window.open('<%= answeb %>', 'newwin', 'width=800, height=400, scrollbars=yes, resizable=yes, left=112, top=184')"><font color="#003366"><%= ques %></font></a>

it works, but im thinking there's any easier way, possibly incorporating another ASP page which would select that particular question, and display it and the answer. the only thing i can't figure out is how to pass some type of variable (like DATE) through the hyperlink so that the ASP only pulls the particular FAQ with that date out of the DB.

any ideas?

thanks in advance.

Bullschmidt
01-10-2006, 02:56 PM
Perhaps this may hopefully give you some ideas:

Classic ASP Design Tips - QueryString
http://www.bullschmidt.com/devtip-querystring.asp

jjr0319
01-10-2006, 03:58 PM
thanks bullschmidt. i think i get the idea, but im having trouble. what i did was create a new field in my DB called QUES, which holds the question number starting at 1001. my link is <a href="ansview.asp?Q=<%= QUES%>">, so that when clicked it produces this URL <ansview.asp?Q=1001>. what i cant figure out is how to then get that URL variable to display the answer for 1001 from the DB. i thought i could do something like this:

Qstring = Request.QueryString("Q")

strSQL = strSQL & "SELECT * FROM FAQ WHERE FAQ.QUES='%" & Qstring & "%'"

but it doesnt work. what am i doing wrong?

thanks for the help.

Bullschmidt
01-10-2006, 04:04 PM
In ansview.asp:

Ques = Request.QueryString("Ques")

' Set strSQL.
strSQL = "SELECT * FROM MyTable WHERE Ques=" & Ques

jjr0319
01-10-2006, 04:10 PM
tried that and am getting a datatype mismatch error

Bullschmidt
01-10-2006, 04:14 PM
Well if Ques is a text field instead of numeric then change this:
strSQL = "SELECT * FROM MyTable WHERE Ques=" & Ques

To be more like this instead:
strSQL = "SELECT * FROM MyTable WHERE Ques='" & Ques & "'"

jjr0319
01-10-2006, 04:15 PM
nevermind, i got it working. had the wrong field typed in the SQL statement.

thanks for all the help bullschmidt. really appreciate it.

Bullschmidt
01-10-2006, 04:41 PM
You're welcome and way to go yourself!