Jump to content

Hide Fields with Predefined Words


chrepair

Recommended Posts

Hello all.I am using ASP and have a database and a page to display the data in the database.What I want to do is have my display page show the word "RESERVED" for fields in my database that have SOMETHING (words, letters, numbers, characters-etc) typed in them. For fields that are blank or have nothing in them I want the word "AVAILABLE" displayed on the page. Below is the code that I have for the display page.Any idea's?<meta http-equiv="refresh" content="30"> <html><style>#MainTable th{ width: 50px; color: #000099; font-size: 24; font-family:andy;}</style><style type="text/css"><!--.style1 { font-family: Georgia, "Times New Roman", Times, serif; font-size: 10px;}body { background-color: #000000;}--></style><%dim nameaval="AVAILABLE"%><body><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("northwind.mdb"))set rs = Server.CreateObject("ADODB.recordset")sql="SELECT Time, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday FROM greg"rs.Open sql, conn%><table id="MainTable" width="750" height="20" border="2" align="center" cellpadding="0" bordercolor="#0000FF" bgcolor="#00FFFF"><tr><%for each x in rs.Fields response.write("<th align='center' bgcolor='#00CCFF' font-family:andy>" & x.name & "</th>")next%></tr><%do until rs.EOF%> <tr> <%for each x in rs.Fieldsif x.name = "Time" then%><td align="center" valign="middle" style="background-color:#000099;font-family:Andy;color:#FFFF00;font-size:15pt;font-weight:bold;border:1px solid #666666"><%else%><td align="center" valign="middle" style="background-color:#66FFFF;font-family:Georgia;color:#663300;font-size:12pt;font-weight:normal;border:1px solid #666666"> <span class="style1"><%end if%><%Response.Write(x.value)%></div> </span> <div align="center"></div></td><%next rs.MoveNext%> </tr><%looprs.closeconn.close%></table></body></html>

Link to comment
Share on other sites

I removed the html formatting for ease of reading. Good luck.<% for each x in rs.Fields if trim(x.name) = "" then Response.write("AVAILABLE") else Response.write("RESERVED") end if%></td><%next rs.MoveNext%> </tr><%looprs.closeWhat I want to do is have my display page show the word "RESERVED" for fields in my database that have SOMETHING (words, letters, numbers, characters-etc) typed in them. For fields that are blank or have nothing in them I want the word "AVAILABLE" displayed on the page. <%for each x in rs.Fieldsif x.name = "Time" then%><td align="center" valign="middle" style="background-color:#000099;font-family:Andy;color:#FFFF00;font-size:15pt;font-weight:bold;border:1px solid #666666"><%else%><td align="center" valign="middle" style="background-color:#66FFFF;font-family:Georgia;color:#663300;font-size:12pt;font-weight:normal;border:1px solid #666666"> <span class="style1"><%end if%><%Response.Write(x.value)%></div> </span> <div align="center"></div></td><%next rs.MoveNext%> </tr><%looprs.closeconn.close%></table></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...