• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFML help

Participant ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

I dont know if this is a CFML question or do i need to use a <script></script>.....please help

I have a <input type="checkbox" name="mcall"> my page looks like this in the browser
<table>
<tr>

<td>Name Address State checkbox</td>
<td>Name Address State checkbox</td>
<td>Name Address State checkbox</td>

</tr>
</table>
Now I want to check the checkbox's and write to a file only the <td> that are checked....I know it can go like

<cfif mcall.checked = true>
<cffile action = "write" file="c:\msg.txt" addnewline="yes" output="What should be my ouput???????">

But i am not sure how to structure the code syntax any help would be great ...or any place where i can find help would be great too thanks
TOPICS
Advanced techniques

Views

584

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , May 25, 2006 May 25, 2006
<cfif not IsDefined("form.mcall")>

Take out the "not" ... as your code stands, you are telling it to write to the TXT file if there are no checked boxes ... you need it to write to the file if it DOES find a checked checkbox.


and yes, you would use "form.mcall" as the output variable


Votes

Translate

Translate
Engaged ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

If your checkboxes are all named the same, then CF will end up with a comma delimited list of values based on what value you assign the checkbox value field.

If you have the required data in the value field of that checkbox, and are writing to a single text file, and you have tested that there are checkboxes checked, simply replace the commas in that list with CHR(10), which is a linefeed character, and write that to the file.

If you need further help, I'll need some more precise details; such as your actual code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

Ok here is the code and the second form which writes the file...thank you for the help....please tell me where i am going wrong.....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

I am guessing one or two things are occurring - you are getting an outright error, or it is not writing the proper data to the file.

To begin with, to detect a checkbox in CF, it should be
<CFIF IsDefined("form.mcall")>

If a checkbox is not checked it will not show up for CF at all

Now, having addressed that issue, all your checkboxes are the same name and have no pre-set value, so therefore you are ending up with a variable called "mcall" populated with a comma delimted list of values equal to the number of checked checkboxes.

Unless you specify a value, the default value of a checkbox is "ON" or "YES" depending on browser. If you have 10 rows of output and 3 checkboxes checked, then the variable "mcall" will contain "ON,ON,ON"

Using your 'static' example, I could explain how to either write the content of "mcall" to the txt file with one "ON" per line, or I could show you how to write the static line of "They make this to easy" 3 times; BUT I actually think you have a different idea in mind.

What, exacty, are you trying to write to that TXT file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

The page has four coulmns

name address state location "checkbox"

If i check one.... I want to write that table row to the txt file...I am not getting an error but
the file is not being written too do to the fact my code is not correct....
If you could show me how i can assign those text values from the other <input types> to the checkbox and how to output those
values to a file that would be great!!! or even how i just assign the values to the checkbox
would be great too...thank you!



Here is what i think you meant by assigning the values to my checkbox......Is this the right idea???


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

<CFINPUT TYPE="checkbox" NAME="mcall" VALUE="what ever you want in here, static or dynamically created by CF">

If this all runs froma database, it could be as simple as a reference ID that can be called again to create the output ... or you could format the exact output for the TXT file from all the data as the value for the checkbox.

Once you get the data Write using the ReplaceNoCase command to change the commas to CHR(10) and it should write each set of data per line.

I have to run to a meeting now, but I'll check back here later - play with it a bit and see what happens.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

Thanks for you help first off...................................Here is what i got.....I set my checkbox value to this

<td align="center" class="rightbottom"><input type="checkbox" name="mcall" id="mcall"
value="#pname#,#dateseen#,#loca#,#vider#"></td>

Now this is how i am trying to output the values in the table rows that are checked.....Do i use #mcall# for the output varible????? thats what i do here and it goes right to that <cfelse>Your Code is Wrong</cfif> here is what i do



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

LATEST
<cfif not IsDefined("form.mcall")>

Take out the "not" ... as your code stands, you are telling it to write to the TXT file if there are no checked boxes ... you need it to write to the file if it DOES find a checked checkbox.


and yes, you would use "form.mcall" as the output variable


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation