ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 10th, 2004, 05:35 PM
Noel4DMB Noel4DMB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 216 Noel4DMB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 56 m 37 sec
Reputation Power: 5
Exclamation Using Form Arrays in CFMX

Hello,

I'm currently trying to retrive an array from a form in CFMX, but am having a few problems. My form has 11 fields, all named 'newentry[]'. So once the array in the form is created, the action does the following:

Code:
	<cfset reginfo = "#form.newentry#(1)">
	<cfset error = arrayNew(1)>
	
	<!--- Search for Blank Fields --->
	<cfloop index="x" from="1" to="11">
	<cfif len(trim(reginfo[x]))>
	 <cfset reginfo[x] = "#HTMLEditFormat(reginfo[x])#">
	 <cfset error[x] = "no">
	<cfelse>
              <cfset error[x] = "yes">
	</cfif>	
	</cfloop>
	
	<cfloop index="x" from="1" to="11">
	<cfoutput>#reginfo[x]#<p></cfoutput>
	</cfloop>


Now, this SHOULD set the array from the form equal to a new array called "reginfo", and then it should check to see if each one is blank, before formatting it and printing out the final results. But its telling me that form.newentry is a part of some java class, and it wont let me do anything.

Is there a special method of formatting arrays from a form that I am unaware of? Thanks!

Reply With Quote
  #2  
Old April 11th, 2004, 12:59 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
What exactly are you trying to do? If you have 11 fields all named the same thing, they are not treated as an array on the target page. What I would recommend is naming each field something like "newEntry1", "newEntry2", etc.

Reply With Quote
  #3  
Old April 11th, 2004, 08:29 AM
Noel4DMB Noel4DMB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 216 Noel4DMB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 56 m 37 sec
Reputation Power: 5
in a form you can name something "variable[]" in order to create an array "$variable". the brackets in the form name signify 0, 1, 2, 3 in order that they appear on the form.

I figured this would be the same for cold fusion since it works perfectly in PHP, but i cant get it to work properly.

Reply With Quote
  #4  
Old April 12th, 2004, 08:11 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
In PHP, form elements are treated as an array. In CF, form elements are treated as a structure (key-value pairs). So if you want to have multiple forms named the same thing, like field1, field 2, etc...that's fine. But you reference it on the target page as "form.field1", "form.field2", etc. You can also reference it with this type of syntax to specify the key: form['field1']

hope that helps.

Reply With Quote
  #5  
Old April 15th, 2004, 11:06 PM
mtangorre mtangorre is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Silver Spring, MD
Posts: 12 mtangorre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to mtangorre Send a message via MSN to mtangorre
Or if you want all the form fields to be named exactly the same, you will get a list of values!

For example:

<input type="checkbox" name="state" value="MD" />
<input type="checkbox" name="state" value="PA" />
<input type="checkbox" name="state" value="NY" />

If a user checked all 3 and submitted the form, form['state'] would be equal to "MD,PA,NY".

Not sure if this applies, but it sounds like it may.

Mike

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Using Form Arrays in CFMX


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway