开发者

Handling CFSELECT

开发者 https://www.devze.com 2023-03-19 00:42 出处:网络
I\'m totally unused to Cold Fusion, I\'d like to know how to handle a multipl开发者_StackOverflow中文版e CFSELECT, in particular how to know how many rows I\'ve selected and taking them one by one.

I'm totally unused to Cold Fusion, I'd like to know how to handle a multipl开发者_StackOverflow中文版e CFSELECT, in particular how to know how many rows I've selected and taking them one by one. Actually I've managed to see all the rows togheter:

  <!--- page_a.cfm --->
  <cfform name="fooform" ........>
  <cfselect query="myquery" name="fornitori" multiple="yes"></cfselect>

  <!--- page_b.cfm --->
  <cfoutput>#form.fornitori#</cfoutput>

And, if it's not too much, I'd like to know why it's not correct to write:

<!--- page_b.cfm --->
<cfoutput>#fooform.fornitori#</cfoutput>


Since it is a multiple selection list, the options you select will be submitted to page_b.cfm as a comma delimited list. This means you can use list functions to calculate the total items selected and cfloop to iterate through the selections individually. Note, when using "multiple" select lists, if you select nothing the form field will not exist.

    <cfparam name="form.fornitori" default="">
    <cfoutput>
      Total Items Selected = <cfoutput>#listLen(form.fornitori)#</cfoutput>
      Individual Selections:<br>
      <cfloop list="#form.fornitori#" index="theSelection">
          #theSelection#<br>
      </cfloop>
    </cfoutput>

why it's not correct to write ..

Because FORM refers to a special system structure, not the name of your html form (ie fooform). FORM contains any form fields submitted via method=POST.


#myquery.recordcount#

btw, use cfdump to display anything. you see some really interesting stuff (I'm not sure whether recordcount is in there though)


getting to the elements:

<cfoutput query="queryname">#title#<br />#content#</cfoutput>

inside the cfoutput you have access to the variables of an element.

coldfusion 9 help

0

精彩评论

暂无评论...
验证码 换一张
取 消