Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
sviolet #1
Repeating output with cfif statement
I have a problem when multiple checkboxes are "turned on' when multiple values
exist for a field in a database. For example:
The following code produces the following output:
<cfif #INSTREAM_TYPE# IS "Stormwater Outfalls">
<input type="checkbox" name="INSTREAM_TYPE" value="Stormwater"
checked>Stormwater Outfalls<br></CFIF>
<cfif #INSTREAM_TYPE# IS NOT "Stormwater Outfalls">
<input type="checkbox" name="INSTREAM_TYPE" value="Stormwater">Stormwater
Outfalls<br>
</cfif>
<cfif #INSTREAM_TYPE# IS "Stormwater Detention">
<input type="checkbox" name="INSTREAM_TYPE" value="WaterDent"
checked>Stormwater Detention<br></cfif>
<cfif #INSTREAM_TYPE# IS NOT "Stormwater Detention">
<input type="checkbox" name="INSTREAM_TYPE" value="WaterDent">Stormwater
Detention<br>
</cfif>
<cfif #INSTREAM_TYPE# IS "Habitat Enhancement and Restoration">
<input type="checkbox" name="INSTREAM_TYPE" value="Habitat" checked>Habitat
Enhancement and Restoration<br></cfif>
<cfif #INSTREAM_TYPE# IS NOT "Habitat Enhancement and Restoration">
<input type="checkbox" name="INSTREAM_TYPE" value="Habitat">Habitat
Enhancement and Restoration<br>
</cfif>
Stormwater Outfalls
*Stormwater Detention
Habitat Enhancement and Restoration
*Stormwater Outfalls
Stormwater Detention
Habitat Enhancement and Restoration
What I want the output to look like:
*Stormwater Outfalls
*Stormwater Detention
Habitat Enhancement and Restoration
Any help you could provide would be greatly appreciated
Thanks
sviolet Guest
-
Very odd, page output going into sql statement
Hi, I have completely failed to come up with an explanation for this one. I have a sql statement near the top of my page. The SQL is... -
Help with cfif statement
Can anyone help me find the correct way to write the following statement? <cfif form.user2 NEQ 15 or 50 or 51 or 52 or 53 or 55 or 200 or 223 or... -
CFIF Statement problems
I am trying to write a cfif statement, which shows a form only if the statemnt acts true. It is a 3 part statement, the first two parts appear to... -
Login error with CFIF statement
Hi all: I'm having trouble with a login CFIF routine. The following code works fine when the login is TRUE, but when I try to login with invalid... -
Using cfoutput within a cfif statement
I am trying to setup a form validation, what i need to do is look at the Specimen Number entered and compare it against the database to see if it... -
jorgepino #2
Re: Repeating output with cfif statement
this will reduce the amount of code
<input type="checkbox" name="INSTREAM_TYPE" value="Stormwater" <cfif
#INSTREAM_TYPE# IS "Stormwater Outfalls">checked</CFIF>>Stormwater Outfalls<br>
<input type="checkbox" name="INSTREAM_TYPE" value="WaterDent" <cfif
#INSTREAM_TYPE# IS "Stormwater Detention">checked</cfif>>Stormwater
Detention<br>
<input type="checkbox" name="INSTREAM_TYPE" value="Habitat" <cfif
#INSTREAM_TYPE# IS "Habitat Enhancement and Restoration">checked</cfif>>Habitat
Enhancement and Restoration<br>
jorgepino Guest
-
CFDEBUG #3
Re: Repeating output with cfif statement
Do you have this code within a loop?.
Also you could combine two cfifs into one by doing this
<input type="checkbox" name="INSTREAM_TYPE" value="Stormwater" <cfif
instream_type eq "Stormwater Outfalls">checked</cfif>>Stormwater
Outfalls<br></CFIF>
CFDEBUG Guest
-
sviolet #4
Re: Repeating output with cfif statement
Thanks for your help
The following works except for the fact that if a checkbox is not selected -
the checkbox label doesn't show up. How can i make it so a checkbox appears
with a label but is unchecked if the the value doesn't exist? (note: different
variable names in this post)
<input type="checkbox" name="INSTREAM_TYPE" value="Sediment Removal" <cfif
#instream_type# eq "Sediment Removal">checked
<br>Sediment Removal</cfif>
<input type="checkbox" name="INSTREAM_TYPE" value="Vegetation Removal" <cfif
#instream_type# eq "Vegetation Removal">checked
<br>Vegetation Removal</cfif>
<input type="checkbox" name="INSTREAM_TYPE" value="Debris Removal" <cfif
#instream_type# eq "Debris Removal">checked
Debris Removal<br></cfif>
sviolet Guest
-
sviolet #5
Re: Repeating output with cfif statement
I should mention, I am not using a cfloop, just cfoutput:
<CFOUTPUT QUERY="EditQuery2">
<input type="checkbox" name="INSTREAM_TYPE" value="Sediment Removal" <cfif
#instream_type# eq "Sediment Removal">checked
<br>Sediment Removal</cfif>
<input type="checkbox" name="INSTREAM_TYPE" value="Vegetation Removal" <cfif
#instream_type# eq "Vegetation Removal">checked
<br>Vegetation Removal</cfif>
<input type="checkbox" name="INSTREAM_TYPE" value="Debris Removal" <cfif
#instream_type# eq "Debris Removal">checked
Debris Removal<br></cfif>
</CFOUTPUT>
sviolet Guest
-
CFDEBUG #6
Re: Repeating output with cfif statement
Well, you have same variable names. Anyway you need to put the cfif before the
label like this
<input type="checkbox" name="INSTREAM_TYPE" value="Sediment Removal" <cfif
instream_type eq "Sediment Removal">checked</cfif>>
<br>Sediment Removal.
Since you are using query, ofcourse it will show up multiple times since it
loops thru all rows and displays checkboxes that many times. To remove that, do
this
<cfoutput>
<cfset instr_list = valuelist(EditQuery2.instream_type)>
<input type="checkbox" name="INSTREAM_TYPE" value="Sediment Removal" <cfif
listfindnocase(instr_list,"Sediment Removal")>checked</cfif>
<br>Sediment Removal
Do the other 2 checkboxes similar to above. If this has any issue, you could
use quotedvaluelist() instead of valuelist() since this is a string. But I'm
sure valuelist() itself should work.
CFDEBUG Guest
-
sviolet #7
Re: Repeating output with cfif statement
Well, you have same variable names. >>>Sorry my mistake! Anyway you need to
put the cfif before the label like this
<input type="checkbox" name="INSTREAM_TYPE" value="Sediment Removal" <cfif
instream_type eq "Sediment Removal">checked</cfif>>
<br>Sediment Removal.
Since you are using query, ofcourse it will show up multiple times since it
loops thru all rows and displays checkboxes that many times. To remove that, do
this
<cfoutput>
<cfset instr_list = valuelist(EditQuery2.instream_type)>
<input type="checkbox" name="INSTREAM_TYPE" value="Sediment Removal" <cfif
listfindnocase(instr_list,"Sediment Removal")>checked</cfif>
<br>Sediment Removal
type values, the checkbox repeats 3 times)>>>>I tried the above and still the checkbox repeats (if there are 3 instream
???Thanks of your help
sviolet Guest



Reply With Quote

