如何在Coldfusion中从文本框中输入文本值 [英] How to text value from a textbox in Coldfusion

查看:58
本文介绍了如何在Coldfusion中从文本框中输入文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<cffunction name="TEST" returntype="string" output="false">
    <cfreturn "So your name is #name#?")>
</cffunction>

<cfif (isDefined("form.test"))>
<cfoutput>#test()#</cfoutput><br>
</cfif>

<cfform>
<cfinput name="names" type="text">
<cfinput name="TEST" type="submit" value="Call test()">
</cfform>

如何从文本框中获取文本并将其设置为变量?
谢谢!

How to get the text from the textbox and set it in a variable? THANKS!

推荐答案

这就是我要重写的方式。请注意,我删除了 cfform cfinput 表单示例。它们不是必需的,很可能会导致问题。您应该将函数需要的所有数据作为参数传递。

This is how I would re-write this. Please note that I removed cfform and cfinput form example. They are not needed, and will likely cause issues down the road. You should pass in, as arguments, any data your function is going to need.

<cffunction name="test" returntype="string" output="false">
    <cfargument name="name" type="string" required="true" />
    <cfreturn "So, your name is #arguments.name#?" />
</cffunction>

<cfif isDefined("form.name") >
    <cfoutput>#test( htmlEditFormat( form.name ) )#</cfoutput><br>
</cfif>

<form method="post">
    <input name="name" type="text">
    <input name="TEST" type="submit" value="Call test()">
</form>

这篇关于如何在Coldfusion中从文本框中输入文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆