English 中文(简体)
A. 以外地名称形式出现的增值
原标题:Incrementing values in form field names

我需要鉴定X个领域。 每个领域的名称是“试验场X”,其中X实际数字大于1。

因此,基本上,我以一个形式拥有名字的领域是:

testField1
testField2
testField3

等等。

我需要把所有这些内容汇集起来,并加以验证。

让我假设,我有5个领域。

之后

<cfloop index="i" from="1" to="5">
    <cfif form.testField & i EQ "">
        Show error
    </cfif>
</cfloop>

但它没有工作。 我的错误是,外地名称“试验场”不存在,这是真实的(只有测试场1+)。 这似乎与事情并不趋同。 它是否只是用扼子开展工作?

我如何解决这一问题?

最佳回答

The syntax You re following is:

<cfif form["testfield" & i] EQ "">

这将像你所期望的那样,压缩地块。

问题回答
<cfif structKeyExists(form,"test1")>
    <cfloop from="1" to="3" index="i">
        <cfif form["test" & i] eq   >
            Error : <cfoutput>#i#</cfoutput><br />
        </cfif>
    </cfloop>
</cfif>

<form name="sub" method="post">
    Test1: <input type="text" name="test1" id="test1" /><br />
    Test2: <input type="text" name="test2" id="test2" /><br />
    Test3: <input type="text" name="test3" id="test3" /><br />
    <input type="submit" value="Submit" />
</form>




相关问题
JQuery AJAX .load - flash chart doesnt load in IE

An IE issue has me completely stumped. I have a coldfusion page that uses JQuery s AJAX .load function to load in a new flash file that is generated by coldFusion s cfchart tag. This works completely ...

Best Coldfusion Library for OpenID [closed]

I am getting ready to start a project that requires using OpenID within Coldfusion 8. I have found a number of different options and was wondering what has worked the best, get s the most support, ...

Find ColdFusion Generated ID

Is there a way to find the elements generated by ColdFusion s <CFLayout> and <CFLayoutArea> tags? These tags: <cflayout type="tab" name="MyAccount"> <cflayoutarea name="...

ColdFusion COM error

I am upgrading from CF4.5 to CF8. Calls to COM dll s that used to work in version 4.5 now throw a "Complex object types cannot be converted to simple values.." error. The COM object has a few arrays ...

What s the best way to write engine-specific CFML code?

Sometimes it is necessary to write different code for Adobe ColdFusion vs Railo vs OpenBD, due to differences in implementation. Do people have a specific method that they use for this? For example, ...

热门标签