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

Place an "X" in a box

Status
Not open for further replies.

andy570

Technical User
Jan 5, 2004
40
US
Is there a way to use a checkbox selection to place an "X" inside the appropriate box?
 
huh?

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Okay, let me clarify. I have a form on one page. It is for a standard contract. The contract has several sections where a box needs to be checked. For example: Do you have knowledge of existing lead paint?
(BOX) No, I don't
(BOX) Yes, I do.

When the form is processed both selections will appear on the contract however, the appropriate (BOX) will have an "X" through it. Does that make sense?

Thanks for the help.

 
got it now. thanks.

There are a few ways to do it, I'll cover 2.

text X in a table Cell

If you are using tables you could simply do something like this. This is after you save the form and the result is stored in the db obviously.
Code:
<cfquery name = "foo" datasource = "bar">
  SELECT ledPaintKnowledge
  FROM   yourTable
  WHERE  yourCondition = true
</cfquery>
Code:
....
...
...
<td>
<cfif foo.ledPaintKnowledge eq "Yes">X</cfif>
</td>
...
...
...

Another way is to use graphics. Assume i'm using the same query example from above.

Code:
..
...
...
<cfif foo.ledPaintKnowledge eq "Yes"><img src = "boxWithX.jpg"><cfelse><img src = "boxNoX.jpg"></cfif>
...
...
...

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Is this an actual checkbox INPUT tag?

I would do this

Code:
<INPUT type=checkbox name="somename" value=0 
<CFIF #query.answer# EQ "0">SELECTED</CFIF>>&nbspNo, I don't.
<INPUT type=checkbox name="somename" value=0 
<CFIF #query.answer# EQ "1">SELECTED</CFIF>>&nbspYes, I do.

Or if this is a form without a leading query I would just do

Code:
<INPUT type=checkbox name=somename value=0 SELECTED>No, I don't
<INPUT type=checkbox name=somename value=1>Yes, I do

-Al

 
He's talking about on the reporting page. he doesn't want to see an html checkbox he wants to see something more suiting to the report.

also in your example you can't use "selected" with a check box. you'd use "checked"

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Ahh ha. And you're right, it is CHECKED.

-Al
 
Thanks for the help....I used the image source example and it works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top