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

Displaying bit data as option button

Status
Not open for further replies.

kathryn

Programmer
Apr 13, 2000
776
US
Good afternoon,

I have data on my company's job openings in an SQL database. One field, Closed, has a datatype of bit. A value of 1 indicates that the job has been filled and is closed, while a value of 0 indicates that the job is still open.

I am creating an administration form for our HR department to maintain this data online. I am using a query to pull the information on all the jobs in the table into a form. Actually, one query populates a drop down list of all jobs and the selection of one of the jobs populates the rest of the form. I want to use the values of Closed to check one of two option buttons on the form:

<cfinput type=&quot;radio&quot; name=&quot;Closed&quot; value=&quot;Open&quot;>Open
<cfinput type=&quot;Radio&quot; name=&quot;Closed&quot; value=&quot;Closed&quot;>Closed

The value of the field Closed is contained in a variable named dspClosed. Do I use a <cfif> tag?

I tried:

<cfinput type=&quot;radio&quot; name=&quot;Closed&quot; value=&quot;Open&quot; <cfif dspclosed==&quot;0&quot;>checked</cfif>>Open
<cfinput type=&quot;Radio&quot; name=&quot;Closed&quot; value=&quot;Closed&quot; <cfif dspclosed==&quot;1&quot;>checked</cfif>>Closed

But CF doesn't like the cfif withing the cfinput tag.

My problem is that I don't know to modify the option/radio button statements above to show the correct value. Currently, they don't show anything.

Any help, ideas, war stories, reference would be greatly appreciated.

Kathryn


 
You can't embed any conditions into a <cfinput> tag, as far as I know. You'll have to do it something like this:

<cfif dspClosed>
<cfinput type=&quot;Radio&quot; name=&quot;Closed&quot; value=&quot;Open&quot;>Open
<cfinput type=&quot;Radio&quot; name=&quot;Closed&quot; value=&quot;Closed&quot; checked>Closed
<cfelse>
<cfinput type=&quot;Radio&quot; name=&quot;Closed&quot; value=&quot;Open&quot; checked>Open
<cfinput type=&quot;Radio&quot; name=&quot;Closed&quot; value=&quot;Closed&quot;>Closed
</cfif> Andrew
 
One other point:

Your syntax of &quot;<cfif dspclosed==&quot;0&quot;>&quot; needs to be &quot;<cfif dspclosed IS &quot;0&quot;>&quot; or &quot;<cfif spclosed EQ &quot;0&quot;>&quot;. Unless they changed it in 4.5, the &quot;==&quot; comparison is not a CF operator.

Good Luck,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top