Highlighted

Coma at the end of each eanswer of my checkbox

New Here ,
Mar 21, 2019

Copy link to clipboard

Copied

I have a simple query for a list using checkbox :

<cfloop query="getlist">

#thingstodo# : <input type="checkbox" name="thingstodo" value="<br/>#thingstodo#"> <p>

</cfloop>

So it will apear like this :

Some list of things to do 1 : <input type="checkbox" name="thingstodo" value="<br/>Some list of things to do 1"> <p>

Some list of things to do 2 : <input type="checkbox" name="thingstodo" value="<br/>Some list of things to do 2"> <p>

Some list of things to do 3 : <input type="checkbox" name="thingstodo" value="<br/>Some list of things to do 3"> <p>

Some list of things to do 4 : <input type="checkbox" name="thingstodo" value="<br/>Some list of things to do 4"> <p>

My problem is it adds a coma at the end and this is how it looks in the database :

<br/>Some list of things to do 1,<br/>

Some list of things to do 2,<br/>

Some list of things to do 3,<br/>

Some list of things to do 4,<br/>

Some list of things to do 5,<br/>

I tryed using replace before i send it in the databse but i think i'm doing it wrong plus some of the text in the list might have a coma in it so this might not be the answer:

<cfset thingstodo = Replace(thingstodo, ",","","ALL")>

Thanks for your help

Views

83

Likes

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

Coma at the end of each eanswer of my checkbox

New Here ,
Mar 21, 2019

Copy link to clipboard

Copied

I have a simple query for a list using checkbox :

<cfloop query="getlist">

#thingstodo# : <input type="checkbox" name="thingstodo" value="<br/>#thingstodo#"> <p>

</cfloop>

So it will apear like this :

Some list of things to do 1 : <input type="checkbox" name="thingstodo" value="<br/>Some list of things to do 1"> <p>

Some list of things to do 2 : <input type="checkbox" name="thingstodo" value="<br/>Some list of things to do 2"> <p>

Some list of things to do 3 : <input type="checkbox" name="thingstodo" value="<br/>Some list of things to do 3"> <p>

Some list of things to do 4 : <input type="checkbox" name="thingstodo" value="<br/>Some list of things to do 4"> <p>

My problem is it adds a coma at the end and this is how it looks in the database :

<br/>Some list of things to do 1,<br/>

Some list of things to do 2,<br/>

Some list of things to do 3,<br/>

Some list of things to do 4,<br/>

Some list of things to do 5,<br/>

I tryed using replace before i send it in the databse but i think i'm doing it wrong plus some of the text in the list might have a coma in it so this might not be the answer:

<cfset thingstodo = Replace(thingstodo, ",","","ALL")>

Thanks for your help

Views

84

Likes

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
Mar 21, 2019 0
LEGEND ,
Mar 21, 2019

Copy link to clipboard

Copied

When you have a few checkboxes with the same name, depending upon which version of CF you are using the form submits those checkbox values as either a comma-delimited list or an array.  Apparently you're using an older version of CF that submits the values as a comma-delimited list.

If any of the values contain a comma, this will make things extremely difficult as anything that works with lists will detect every comma as a delimiter.  The option to avoid this is to use an HTML entity to represent commas in the value, allowing the comma to still appear in a browser but will not screw up the list.  Then, join the values replacing the delimiting comma with a line break <br />.

V/r,

^ _ ^

Likes

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
Reply
Loading...
Mar 21, 2019 0