简体   繁体   中英

Concatenate form element name with coldfusion counting variable

I'm trying to access individual form elements within a cfquery tag using the form.elementName + countingVariable. Can someone tell me what the syntax is to do this properly.

<form>
<select name="SetID0">
<option></option>
...
</select>
</form>

<cfquery>
<cfqueryparam value="#"form.SetID & #i#"#" CFSQLType="CF_SQL_CHAR">,
</cfquery>

I know there may be a better way of doing this like creating a list and I'm open to those suggestions but I'd like to know if what I'm trying to do now is possible.

你大部分都在那里

<cfqueryparam cfsqltype="cf_sql_char" value="#form['setID' & i]#">

First change the pull-down menus

<form>
<select name="SetID" multiple>
  <option></option>
  ...
</select>
</form>

There are UI widgets that make this type of pulldown menu very clean. Consider Select2

Then change the query

<cfquery>
   fieldname IN  (
     <cfqueryparam value="#form.SetID#" CFSQLType="CF_SQL_CHAR" list="yes">
     )
</cfquery>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM