If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP code HELP!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-02-03, 16:39
davec99 davec99 is offline
Registered User
 
Join Date: Jul 2003
Posts: 1
ASP code HELP!

Hi all, I'm hoping that someone out there can help me

Here's the task... I need to manipulate some code (see below) so I can attribute a background color to a set of categories/subcategories. I will add a column to the categoreies table in access in order to specify the color - i.e. #ffffff

But I need some help to edit the code - to call the new field 'catbgcolor' which will be a TD attribute - i.e. normally <TD BGCOLR=#FFFFFF>

Object is to color code my category links to make site navigation easier

Any help would be appreciated

Dave

Here's the code:
------------------------------------
dim dbc
shoppageheader
shopopendatabase dbc
Displaycategories
shopclosedatabase dbc
shoppagetrailer

'************************************************* **************************
sub Displaycategories
dim sql, rs, level, rc, catdescription, spacing, categoryid
dim highercategoryid, hassubcategory
highercategoryid=0
Generatesql sql, highercategoryid
set rs=dbc.execute(sql)
CreateCattable
do while not rs.eof
Getcategoryfields rs,categoryid, hassubcategory, catdescription, rc
If rc=0 then
spacing=0
Formatcategory categoryid, catdescription, spacing
If hassubcategory<>"" then
Formatsubcategories categoryid,spacing
end if
end if
rs.movenext
loop
closerecordset rs
Response.write "</td></tr></table>"
end sub

Sub Createcattable
Response.write "<table width='60%'>"
response.write "<tr>"
response.write "<td align=left>"
end sub
'
Sub Getcategoryfields (rs, categoryid, hassubcategory, strcategory, rc)
dim strcathide
categoryid=rs("categoryid")
strcategory=rs("catdescription")
hassubcategory=rs("hassubcategory")
If isnull(hassubcategory) then
hassubcategory=""
end if
strcathide=rs("cathide") ' hide field
if isnull(strcathide) then
rc=0
else
rc=4
end if
end sub

Sub Generatesql (sql, highercategoryid)
SQL="Select * from categories "
sql = Sql & " where highercategoryid=" & highercategoryid
if getconfig("xproductmatch")="Yes" then
sql=sql & " and productmatch='" & xproductmatch & "'"
end if
if getconfig("xproductmatchcustomer")="Yes" then
if GetSess("CustomerProductGroup")<>"" then
sql=sql & " and customermatch='" & getsess("customerProductgroup") & "'"
end if
end if
Handle_selectcategoriesbylanguage sql
sql=sql & " order by " & Getconfig("xsortcategories")
end sub

Sub Formatcategory (id, name, spacing)
dim i
If spacing>0 then
for i = 0 to spacing
response.write "&nbsp;&nbsp;"
next
end if
response.write "<a HREF=""shopdisplayproducts.asp?id=" & id & "&amp;cat=" & Server.URLEncode(name) & """>" & name & "</a>" & "<br>" & vbcrlf
end sub

Sub Formatsubcategories (categoryid, spacing)
dim sql, rs, rc, catdescription, hassubcategory
Generatesql sql, categoryid
Set rs=dbc.execute(sql)
spacing=spacing+1
do while not rs.eof
Getcategoryfields rs,categoryid, hassubcategory, catdescription, rc
If rc=0 then
Formatcategory categoryid, catdescription, spacing
If hassubcategory<>"" then
Formatsubcategories categoryid, spacing
end if
end if
rs.movenext
loop
spacing=spacing-1
closerecordset rs
end sub

sub Handle_selectcategoriesbylanguage (sql)
If getconfig("xselectproductsbylanguage")="Yes" and getsess("language")<>"" then
sql=sql & " and (catlanguage='" & getsess("language") & "'"
sql=sql & " or catlanguage is null)"
end if
end sub
%>

-----------------------------------------

Last edited by davec99; 07-02-03 at 16:43.
Reply With Quote
  #2 (permalink)  
Old 07-10-03, 20:36
rhs98 rhs98 is offline
Super Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 441
This is really easy to do, but its late, your code is badly formatted and I just can't take it all in right now;

basically what you need to do is to find the bit where the fields are read from the record set (and where they are outputted) and modify the code accordingly.

Easiest way would be to find the person who wrote this...Trust me it really should be very simple. I am just sooooo tired (sorry)
Reply With Quote
  #3 (permalink)  
Old 07-18-03, 09:26
Compaqx101x Compaqx101x is offline
Registered User
 
Join Date: Jul 2003
Posts: 3
Code is confusing...umm it looks like your table code will be:
<table width=60%>
<tr>
<td align=left>

...loop through all links here

</td>
</tr>
</table>

if this is the case you only have one table cell. you need a </td></tr><tr><td> every time you want to create a new cell with a new background color. So put that in your loop somewhere... Then to get your background color do something like
Response.Write("<TD bgcolor=" & rs.Fields("tablebackgroundcolor") & ">")
instead of tablebackgroundcolor put whatever the field name is with the color in it...i think that should do it i'm too lazy to look up the exact commands right now...actually i'm surprised that code works with some of the stuff it does. oh well whatever works...good luck
Compaq
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On