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

Loop PHP to CF, how make?

Explorer ,
Apr 01, 2013 Apr 01, 2013

Guys,

I have the script PHP below.

How I write this script in ColdFusion, sorry for the dummie's ask

<?php

          if(isset($_POST[“color”])) {          

             for($i = 0; $i < count($_POST[“color”]); $i++) {

                  echo “The color “.$_POST[“color”][$i].” was selected!<br />”;

              }

          } else {

              echo “blablablablablablablabla”

          }

?>

[ ]'s

580
Translate
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
LEGEND ,
Apr 01, 2013 Apr 01, 2013

I assume on the form, colour is a series of checkboxes.

if (StructKeyExists(form, "color") {

for (i = 1; i lte ListLen(form.color); i++)

writeoutput("The color #ListGetAt(form.color, i)# was selected<br>") ;

}

else {

}

Translate
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
Explorer ,
Apr 02, 2013 Apr 02, 2013

Hi Dan,

Tks for your answer, my doubt is.  Where putting this code, inside a tag <cfscript> or a <cfif>.

You Could, show me a example?

Thanks one more time.

[ ]'s

Fabiano Magno Pechibella

Translate
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
LEGEND ,
Apr 02, 2013 Apr 02, 2013

The code I wrote would go inside a set of <cfscript> tags.  The tag based version would be:

<cfif StructKeyExists(form, "color")>

<cfoutput>

<cfloop list = "#form.color#" index = "ThisColor">

The color #ThisColor# was selected.<br>

</cfloop>

<cfoutput>

<cfelse>

code for no boxes checked.

</cfif>

Translate
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
Explorer ,
Apr 02, 2013 Apr 02, 2013
LATEST

Great Dan,

You are the best.

Hug's from Brazil.

Fabiano Magno Pechibella

Translate
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