Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input type id

Status
Not open for further replies.

cfvogue

Technical User
Jul 23, 2001
57
NL
Hi all,

I know you can give an id to an input type in a form, but how can you read this on the action page?
e.g.

<form action=&quot;...
<input type=&quot;text&quot; name=&quot;itn&quot; id=6>
</form>
 
When you arrive at the action page (the page specified in your form tag) you will then be able to read any data sent by that form using the syntax...

FORM.NAME

where NAME is an input field you have named. The variable will contain the value of that field. Mitch Duszynski
Web Developer
Human Kinetics
PO Box 5076, Champaign, IL 61825
Tel: 217-351-5076 x2474 | Fax: 217-351-2674
mitchd@hkusa.com |
 
I don't believe ColdFusion can read the ID's of a form tag, only the NAME's and VALUE's. - tleish
 
That is very true tleish.

Hey cfvogue try this:

<form action=&quot;...
<input type=&quot;text&quot; name=&quot;itn&quot; value=&quot;6&quot;>
</form>

Now, if you really need to pass another parameter with the same form input, like COLOR, you can pass both within the same value attribute.

Pass the two values as a list, delimited by a dash.

<form action=&quot;...
<input type=&quot;text&quot; name=&quot;itn&quot; value=&quot;6-green&quot;>
</form>

To access the ID and the COLOR on a CF action page:

<CFSCRIPT>
temp.id = listGetAt(form.itn, 1, &quot;-&quot;);
temp.color = listGetAt(form.itn, 2, &quot;-&quot;);
</CFSCRIPT>

 
tnx strantheman,

That's a nice idea. Strange though that ID in an input type cannot be read by CF.
 
Technically the problem doesn't stem from CF, it stems from the browsers. It's the browsers that pass the value from one page to the next, and if they passed the id from one page to the next then no doubt CF would be able to read it. You can't read the id an any other language either (ie Perl, PHP, ASP, JSP, etc).

strantheman has one of the better solutions to get done what you want accomplished. - tleish
 
What I actually wanted to do is fill an Array in a loop with values of input types that are generated in a loop as well. Any suggestions?

E.G.

<form action=&quot;actionpage.cfm&quot; method=&quot;post&quot;>
<cfloop from=&quot;1&quot; to=&quot;10&quot; index=&quot;counter&quot;>
<input type=&quot;text&quot; name=&quot;itn-#counter#&quot;>
</cfloop>
</form>

On the action page:
<cfset aMyArray = ArrayNew(1)>
<cfloop from=&quot;1&quot; to=&quot;10&quot; index=&quot;counter&quot;>
<cfset aMyArray[#counter#] = #form.int-counter#
</cfloop>

This is not gonna work of course. It Errors on #form.int-counter#.
It sounds like that variable in variable question that was asked here a couple of days ago. Is there any solution to this problem?

tnx
 
Try this:

Use something else other than &quot;-&quot; like &quot;_&quot;, or your code will try to use it as subtraction.

[COLOR=666666]<!--- formpage.cfm --->[/color]
<cfoutput>
[COLOR=000080][COLOR=CC3300]<form action=&quot;action.cfm&quot; method=&quot;post&quot;>[/color][/color]
<cfloop from=&quot;1&quot; to=&quot;10&quot; index=&quot;counter&quot;>
[COLOR=000080][COLOR=CC3300]<input type=&quot;text&quot; name=&quot;itn_#counter#&quot;>[/color][/color]
</cfloop>
[COLOR=000080][COLOR=CC3300]<input type=&quot;Submit&quot;>[/color][/color]
[COLOR=000080][COLOR=CC3300]</form>[/color][/color]
</cfoutput>


Now the form is a structure and we can access variables from it using form
Code:
[
&quot;formfieldname&quot;
Code:
]
. If there's anyway to avoid things like Evaluate() function, it will definately speed up your code.

[COLOR=666666]<!--- Actionpage.cfm --->[/color]
<CFSCRIPT>
aMyArray = ArrayNew(1);
for(i=1; i lte 10; i = i + 1){
aMyArray
Code:
[
i
Code:
]
= form
Code:
[
&quot;itn_#i#&quot;
Code:
]
;
}
</CFSCRIPT> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top