Click to See Complete Forum and Search --> : Help using variables


jporven
03-19-2003, 06:08 PM
I have a shopping cart script called with the following code:

If Not IsNull(rs("RETAIL_COST")) Then
Response.Write "<img src=""img/bar_red.gif"" width=4 height=4 hspace=4 align=absmiddle><font"&FC&" size=2><B>Retail Price:</B> " & FormatCurrency(rs("RETAIL_COST")) & "<BR>"
End If


I believe the RETAIL_COST in the code above to be a variable pulled from the database.

I'd like to know how I can place this variable into my HTML and have it "processed" so when the html is displayed it shows the retail cost. I think this is doable asthe cart's documentation says that there are "database variables" that can be used such as <%=pg_header%> ; but it doesn't discuss how to use other variables found within the code or the format to use the example variables in HTML. In other words say I used the <%=pg_header%>, do I need any other tags/code to tell the html page to somehow process this tag? If I want to use other variable I see in the code, such as the RETAIL_COST, woud I use the same format (eg <%=RETAIL_COST%>.

Sorry to trouble the group with this, but I have been back and forth with the developers for weeks andthey are not very helpfull, my only other resort would be shelling out another $500 for a different script.

Thanks in advance for all help.

Ribeyed
03-19-2003, 07:06 PM
hi,
i think you almost have the concept so i'll try fill in some gaps for you.
There are 2 objects most commonly use in ASP, the request and the response objects.
The request object is used to request (and process)input information from forms, querystrings etc.
The response object is used to write out to screen. You can response.write a variable out to screen with data requested with the request object.
Here is an example of requesting data sumbited from a form and displayed on the screen:


<%
username = request.form("UserName")
response.write username
%>


There is a short way of writing response.write, here is an example:

<%=username%>

so you could have written this and have the same results:


<%
username = request.form("UserName")
%>
<%=username%>


When creating dynamic pages we use recordsets to work with the database.
When creating variables or writing out to screen, from the recordset we have to declaire the recordset first. For example:


<%
username = RS("Username")
response.write username
%>

This would create a variable called username and fill it with data from the recordset called RS and the field called username, then write to screen.
Again there is a short way to write this:


<%=RS("Username")%>


So your wanting to display the value RETAIL_COST on you page, this is comming from the recordset RS so you would use the syntax:

<%=RS("RETAIL_COST")%>


Hope this helps you out