Yeah, the file fields was me too.

You don't do a server request, you do it all client-side with
javascript.  I didn't test this, but here's the general idea:

<script type="text/javascript">
  window.emailFieldCount = 1;
  function addField() {
    var div = document.getElementById("fieldContainer");
    div.innerHTML += '<input name="email' + ++window.emailFieldCount +
'" /><br />';
  }
</script>
<div id="fieldContainer">
 <input name="email1" /><br />
</div>
<a href="javascript:addField();">add field</a>

Walking through the code, we've got a single field hard coded in the
page, along with a field count stored in a variable
(window.emailFieldCount), which is initalized to one (because of the
one hard coded field).  When you click the 'add field' link, the
addField() function is called, which find the div that contains the
input fields, and adds another field to the end, incrementing the
field count variable and using it to set the field name to be unique. 
I've opted to use innerHTML rather than the DOM for appending the
fields for simplicity's sake; either should work.

This is a first little window into building javascript RIAs, where the
entire app no longer resides on the server, but part of the UI
controller has moved to the client.

cheers,
barneyb

On Sat, 26 Mar 2005 14:01:16 -0500, Rick Faircloth
<[EMAIL PROTECTED]> wrote:
> Hi, Barney...
> 
> I think it was you, perhaps, who suggested the same
> approach to dynamically adding CFFILE fields to a page
> so that any number of photos could be uploaded at once.
> 
> In the email below, you suggest adding a button/link to click
> so another field would be added for email addresses.
> 
> What the code overview on this...just have the page submit
> back to itself, check a variable of some sort, and if it's a certain
> value have another field show up?
> 
> Care to elaborate on the process you're thinking of?
> 
> Rick

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:200101
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to