Look into the createElement() function. Works like a charm.
Here is some pseudo...
<script>
function addfld(incrementer)
{
//Build the form field
Newfld = document.createElement('input')
Newfld.type = "text";
Newfld.name="mynewfield" + incrementer;
document.getElementById('myContainer').appendChild(Newfld)
//Add a line break
document.getElementById('myContainer').appendChild(document.createElement('b
r'));
}
</script>
<a href="javascript:void(0)" onclick="addfld('2')">Add New Field</a>
<div id="myContainer">
<input type="text" name="mynewfield1"><br>
</div>
Completely off the top of my head so im sure there are errors in it but
hopefully you get the idea.
Just look up createElement() and appendChild(). Let me know if you need
anymore help with it if you decide to go this way. I've got some pretty
cross browser friendly versions of it.
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: Michel Deloux [mailto:[EMAIL PROTECTED]
Sent: Monday, October 24, 2005 4:55 PM
To: CF-Talk
Subject: SOT - Creating dynamically name field with JS
Hi all
sorry by OT but I need your help in JS.
I have a form with only one field. I'll like to present that field
with an option for insert more fields like that and/or exclude others
fields. This is my form:
<form name="frm" action="post">
<INPUT size="50" maxlength="20" name="datefield" onKeyPress="return false;">
<SCRIPT language=javascript>
document.write("<input type=button
onclick='popUpCalendar(this,
frm.datefield, \"mm/dd/yyyy\")' value='Click here and choose your
date'>")
</SCRIPT>
</form>
I tested several methods for include/exclude but I don't know how to
insert that popUpCalendar script inside new field with dynamic name
field.
What's wrong? How to create dynamically name field for my popUpCalendar?
Thanx for your time.
Cheers
MD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:222127
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54