Print Page | Close Window

show hide table records

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=16326
Printed Date: 29 March 2026 at 8:51pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: show hide table records
Posted By: urko
Subject: show hide table records
Date Posted: 25 August 2005 at 7:59am
Hey guys

I have some problem that I can't solve!
I'm using Candypress store and I have made additional table in db to be shown when users click to category 4.

Now I have added this in prodview.asp page where I inserted the tables, but no luck:
Quote
<%
If category = 4 then
'show table1
end if
%>

Is this the right thing or needs more coding??Confused


-------------
Urko



Replies:
Posted By: wingking
Date Posted: 25 August 2005 at 12:47pm
well for one thing you commented out the show table 1


Posted By: theSCIENTIST
Date Posted: 25 August 2005 at 8:52pm
The commented line I think is just to say that's where the code to show table is placed.

Without knowing more about the mechanics of this application, is difficult to say what's wrong.

Can you post more code, or tell us how it works?

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: urko
Date Posted: 26 August 2005 at 3:05am
Quote <table width="100%" border="0" cellpadding="0" height="20" cellspacing="0">
      <tr><td width="80%"><b>View Loads:</b></td><td width="20%"><div align="right"><b><a href="add_load.asp?id=<%=(cartridges.Fie lds.Item("id").Value)%>">ADD Your LOAD:</a></b></div></td>
     
    </tr>
    </table>
    <table width="100%" border="0" cellpadding="0" height="20" cellspacing="0" style="border:1px solid #000000;" bgcolor="#f4f4f4">
         <!--DWLayoutTable-->
              <tr>
                <td width="15%" valign="middle" style="padding-left:5px;"><strong>Load ID #</strong></td>
                      
                     <td width="30%" valign="middle" style="padding-left:5px;"><strong>Bullet weight / type</strong></td>
                     <td width="30%" valign="middle" style="padding-left:5px;"><strong>Powder</strong></t d>
                     <td width="25%" valign="middle" style="padding-left:5px;"><strong>Unit</strong></td& amp; amp; gt;
              </tr>
            </table>
    <div align="center">
           <% If  loads.EOF Or  loads.BOF Then
  Response.Write("<br>No loads yet!<br><br>Be the first to add load for <b>" & cartridges("Title")&"</b> caliber!")
Else
  %>
           <%
While ((Repeat1__numRows <> 0) AND (NOT loads.EOF))
%>
            <table width="100%" border="0" cellpadding="0" height="20" cellspacing="0" style="border-bottom:1px solid #000000;border-right:1px solid #000000;border-left:1px solid #000000;" bgcolor="">
                <!--DWLayoutTable-->
                <tr>
                &a mp;a mp;n bsp; <td width="15%" valign="middle" style="padding-left:5px;"><div align="left"><a href="#" onClick="MyWindow=window.open('http://myserver/loads_display.asp?load_id=& amp; lt;%=(loads.Fields.Item("Load_id").Value)%>','MyWindow','toolbar=no,location=no,directories =no,st atus=no,menubar=no,scrollbars=no,resizable=no,width=500,height=620'); return false;">&a mp;l t;%=(loa ds.Fields.Item("Load_id").Value)%></a></div></td>
                    
                  <td width="30%" valign="middle" style="padding-left:5px;"><div align="left"><%=(loads.Fields.Item("bul let_weight").Value)%>&nbsp;<%=(loads.Fields.Item("bullet").Value)%></div></t d& gt;
                   <td width="30%" valign="middle" style="padding-left:5px;"><div align="left"><%=(loads.Fields.Item("pow der").Value)%></div></td>
                &a mp;a mp;n bsp;    <td width="25%" valign="middle" style="padding-left:5px;"><div align="left"><%=(loads.Fields.Item("unit_mettric_english ").Value)%> </div></td>
                </tr>
              </table>
            <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  loads.MoveNext()
Wend
%>
            <br>
            <%
For i = 1 to loads_total Step MM_size
TM_endCount = i + MM_size - 1
if TM_endCount > loads_total Then TM_endCount = loads_total
if i <> MM_offset + 1 Then
Response.Write("<a href=""" & Request.ServerVariables("URL") & "?" & MM_keepMove & "offset=" & i-1 & """>")
Response.Write(i & "-" & TM_endCount & "</a>")
else
Response.Write("<b>" & i & "-" & TM_endCount & "</b>")
End if
if(TM_endCount <> loads_total) then Response.Write(" ")
next
 %>
            <% end if ' load%>


Ok, now the thing is that I would like to use this page for displaying records from catID 1,2,3,4 and 5, but would like to hide above code if catid is 1,2,3 and 5 is displayed!
The reason is that if you choose catid 4 you could add some informations ( add ballistic loads etc..) but if you choose catID 1,2,3,5 you can add comments to certain product.



-------------
Urko


Posted By: theSCIENTIST
Date Posted: 26 August 2005 at 7:36am
Originally posted by urko urko wrote:

Ok, now the thing is that I would like to use this page for displaying records from catID 1,2,3,4 and 5, but would like to hide above code if catid is 1,2,3 and 5 is displayed!...

I still don't get the point, your declaration above seam to be in conflict, first you say you want to use the code above to show catID 1,2,3,4,5 then you say you don't want to use the code above to show catID 1,2,3,...,5, just 4. Could it be that you just want to use it to display cat 4?

Another thing with the code is that it's very messy, you could filter cat 4 only on your SQL stat, or on the [While/Wend] loop do this:

While Repeat1__numRows <> 0 And NOT loads.EOF And loads.Fields.Item("catID").Value = 4

...
Wend
Not my prefered method

Why do you have to reference fields like this: [loads.Fields.Item("catID").Value] can't you just [loads.("catID")] or something?

The prefered method to do what you want would be to add optional fields to your cats table, such as [fldShow] a boolean type setting whether to show this cat or not, and [fldType] a string type defining what this category holds, ex. [ballistic loads, comments, etc], also, you shouldn't be referencing cats by ID, IDs should be dynamic, and may change, even if you hook on the the index ID, which don't change until the records is deleted, next time the category is created a new ID will be assigned to it and your code will not work then.

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: urko
Date Posted: 26 August 2005 at 7:59am
Sorry, my mistake.

What I want is that if you click products which are under catID=4,you will see tables and code inside tables.

If you click products which are under catID=1,2,3 or 5 then the tables and and code inside tables would be hidden!
(Hope u know what I mean by thatWink).

The fileds [loads.Fields.Item("catID").Value] were made by Dreamweaver as I i'm still learning asp code, but I have already started to write some code and these codes are written [loads.("catID")]. ( still a newbie  in asp Smile).

Second thing that I would like to learn is, how do you work with check boxes!
Example:
I have made additional cell in DB called Active. If it's uncheked then the record will not be displayed, if checked then it will displayed. The reason I want that is, I want to see the record if it's ok, or does it needs to be repaired before I publish it as it may be miss-information to others!

Can you explain a little what code must be written so that if the checkbox is not checked then record will not be shown?

I have created admin pages but I don't know what code to write so that the checkbox will work properly.

Really appreciate your help,

Thanks,



-------------
Urko


Posted By: wingking
Date Posted: 26 August 2005 at 11:15am
my brain hurts...
but couldn't you just acomplish this with an if statement
if catid = 4 then
response.write blah blah blah
end if



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net