ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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:
  #1  
Old August 1st, 2011, 01:49 PM
korssane korssane is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2011
Posts: 60 korssane User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
How to get values from dynamically created textbox to save in db

Hi Guys i am creating dynamic text boxes and i want to store their values into db,.

any help will be apreciated ..

thanks

code of a quick example of dynamic generated textbox is below:

[code]
<html>
<head>
<script language="javascript">
function init()
{
//element with NO id
// newFieldElementNoId = document.createElement( 'INPUT' );
// newFieldElementNoId.onblur = show;
// document.body.appendChild(newFieldElementNoId);

//element with id
var i;
for ( i=0;i<5;i++)
{
newFieldElement = document.createElement( 'INPUT' );
newFieldElement.setAttribute('id','myfieldid'+i);
newFieldElement.setAttribute('name','myfieldname'+i);
newFieldElement.onblur = show;
document.body.appendChild(newFieldElement);
}
}
function show(){

alert( 'id=' + this.getAttribute('id') + "\n" + 'name=' + this.getAttribute('name') + "\n" + "value=" + this.value );
}
</script>
</head>
<body onload="init()">
</body>
</html>

Reply With Quote
  #2  
Old August 1st, 2011, 02:05 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
One option is to pass a hidden form field that you update to specify the number of dynamic fields (i.e. "3"). When you submit the form, you know there are 3 fields so you can loop from 1 to 3 (or whatever number you pass as the total count) and reference each of them by name and number.

You can also use form.fieldList to get a list of all the form fields that were submitted, and determine how many dynamic fields there are that way.

Or, you can use something like my Form Utilities CFC which lets you name the fields with an array syntax (i.e. "myField[3]" and have CF automatically convert it into an array that you can then loop over.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > How to get values from dynamically created textbox to save in db

Developer Shed Advertisers and Affiliates



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

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap