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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If select box = Closed, set another column = True <-- how?

Status
Not open for further replies.

slakker

MIS
Jun 5, 2003
59
US
Hey guys, i dont know what this is called exactly. but i'll try to explain it the best that I can..

When Editing records, i have a few dynamic select boxes..
I have a Status and Resolved or Not fields..

Below is the code to my dynamic STATUS box.. I'd like to set it so that if Status = Closed, then it passes a True (or Yes) value into my Resolved field.
Thanks in Advance :)
-----------------------------------------------
<select name=&quot;Status&quot; id=&quot;Status&quot;>
<%
While (NOT rs_Status.EOF)
%>
<option value=&quot;<%=(rs_Status.Fields.Item(&quot;Status&quot;).Value)%>&quot; <%If (Not isNull((rs_topics.Fields.Item(&quot;Status&quot;).Value))) Then If (CStr(rs_Status.Fields.Item(&quot;Status&quot;).Value) = CStr((rs_topics.Fields.Item(&quot;Status&quot;).Value))) Then Response.Write(&quot;SELECTED&quot;) : Response.Write(&quot;&quot;)%> ><%=(rs_Status.Fields.Item(&quot;Status&quot;).Value)%></option>
<%
rs_Status.MoveNext()
Wend
If (rs_Status.CursorType > 0) Then
rs_Status.MoveFirst
Else
rs_Status.Requery
End If
%>
</select>
 
Unless I'm mistaken, you can't place VBScript command language If ... Then ... Else ...ElseIf ... End If on one line. Split it up on separate lines to see if this works:
Code:
<option value="<%=(rs_Status.Fields.Item("Status").Value)%>" 
<%
If (Not isNull((rs_topics.Fields.Item("Status").Value))) Then
   If (CStr(rs_Status.Fields.Item("Status").Value) = CStr((rs_topics.Fields.Item("Status").Value))) Then
      Response.Write("SELECTED")
   Else
      Response.Write("")
   End If
End If
%>
><%=(rs_Status.Fields.Item("Status").Value)%></option>
 
I would suggest making the change on your submission page. You could easily just do an if check (if Request.Form("whatever") = "CLOSED" Then status_var = True) on the page submitting to the database.

Your other option is to do if checks as your building your option tags.

I would hesitate to make the Status a boolean, however. If you have the possible STATUS options stored in a database I would just use the same value from that table as the value in your records. Using True/False could confuse anyon who has to later work on it and you run into all kinds of wierdness where you have to do conversions back and forth (like right here, or lter when they choose to search for all status = CLOSED and you have to convert to TRUE, or when your printing stuff out and have to convert TRUE back to CLOSED, etc).

Just my thoughts,
-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top