Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change text color and value depending on database value

Status
Not open for further replies.
Aug 1, 2003
85
US
I have a "submitted" field in the database being propigated by a checkbox on an update page. The checkbox is numeric 1,0. The search page is using
<%=(Recordset1.Fields.Item("Submitted").Value)%> to populate the "Ad Status" section of the repeat region. What I'm trying to do is switch the 1 for "Archived" and the 0 for "Active" (active in red) in the Ad status column... Let me know if I'm chasing my tail. Already tried changing the checkbox on the update page to value=archived and the default value in the database to active but updating the record without the checkbox checked deleted the active value and left the cell blank.
Thanks,
Dan
 
Not exactly sure what your after but think this may help. Put the style deffinitions in the head of your document and the asp code just before the cell you wish to be marked as red or whatever.
Code:
<style type="text/css">
<!--
.adstat1 {
	background-color: #FF0000;
}
.adstat0 {
	background-color: #00FF00;
}
-->
</style>


<%
strClass="adstat" & Recordset1.Fields.Item("Submitted").Value
%>

<td class="<%strClass%>">&nbsp;</td>

Cheech

[Peace][Pipe]
 
The submitted value in the databse is 1 or 0. I wanted to change that value to Active or Archived on the page and I also want to make the Active text red not the background red.


This next bit came from the recordset when I declared the variables
<%
Dim Recordset1__varsubmitted
Recordset1__varsubmitted = "%"
If (Request.Form("submitted") <> "") Then
Recordset1__varsubmitted = Request.Form("submitted")
End If
%>

I wrote this to change the value of 0 to Active while keeping Archived the default...I get the "Archived" to come up but not the "Active", unless I use <= "0"

<%
Dim varisubmitted
varisubmitted = "Archived"
If (Recordset1__varsubmitted = "0") Then
varisubmitted = "Active"
End If
%>
With this for output
<td><span class="style23">&nbsp;<%=Response.Write(varisubmitted)%></span></td>

Now gonna try this from cheech...someone should smack me on the back of my head.

<style type="text/css">
<!--
.adstat1 {font-family: Arial; font-size: 12px; }
.adstat0 {font-family: Arial; font-size: 12px; color: #FF0000; }
-->
</style>

<%
strClass="adstat" & Recordset1.Fields.Item("Submitted").Value
%>

<td><span class="<%strClass%>">&nbsp;<%=Response.Write(varisubmitted)%></span></td>

I'll Let you know
Dan
 
The red text worked great after I put in the =

<td><span class="<%=strClass%>">&nbsp;<%=Response.Write(varisubmitted)%></span></td>

Change the if to reflect the database value instead of the Dimmed recordset variable and put the snippet just above the cell and it works great!

<%
Dim varisubmitted
varisubmitted = "Active"
If (Recordset1.Fields.Item("submitted").Value = "1") Then
varisubmitted = "Archived"
End If
%>

td><span class="<%=strClass%>">&nbsp;<%=Response.Write(varisubmitted)%></span></td>

Thanks Cheech
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top