473,414 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Dynamically added fields not working with calendar field

1
I am trying to attach a calendar field to a dynamically added html code. Initially, the code shows 3 input fields (as shown in the "p_scents" div). When the "Add Another Employer" is clicked, it should generate another 3 inputs( as the ones above). It is working fine for me to generate the first 2 fields (without the calendar field), but when I add the calendar field, it is not working.

Expand|Select|Wrap|Line Numbers
  1. <h2><a href="#" id="addScnt">Add Another Employer</a></h2>
  2.      <div id="p_scents"> <p>
  3.      <label>Employer Name</label><input class="dynamic" type="text" name="employern" id="employern" />
  4.      <label>Job Title</label><input class="dynamic" type="text" name="jtitle" id="jtitle" />
  5.      <label>Start Date </label> <input type="text" name="startd" class="textfield" />
  6.          <script language="JavaScript">
  7.          new tcal ({
  8.          // form name
  9.          'formname': 'form',
  10.          // input name
  11.          'controlname': 'startd' });
  12.  </script>
  13.  </p>
  14.  </div>
  15.   <script type="text/javascript">
  16.  $(function() {
  17.      var scntDiv = $('#p_scents');
  18.      var i = $('#p_scents p').size() + 1;
  19.       $('#addScnt').live('click', function() {
  20.          if( i <= 10 ) {
  21.              $('<p><label>Employer Name</label><input class="dynamic" type="text"     name="employern' + i +'" id="employern" /><label>Job Title</label><input class="dynamic" type="text" name="jtitle' + i +'" id="jtitle" /><label>Start Date </label> <input type="text" name="startd' + i +'" class="textfield" />
  22.          <script language="JavaScript">
  23.          new tcal ({'formname': 'form','controlname': 'startd' + i +''});</script><a href="#" id="remScnt">Remove</a></p>').appendTo(scntDiv);
  24.              i++;
  25.              return false;
  26. }
  27.          else{
  28.              alert('Maximum Reached!');
  29.          }
  30.      });
  31.       $('#remScnt').live('click', function() {
  32.               if( i > 2 ) {
  33.           $(this).parents('p').remove();
  34.                      i--;
  35.              }
  36.              return false;
  37.      });
  38.  });
  39.  </script> 
  40.  
Jul 1 '11 #1
1 2040
acoder
16,027 Expert Mod 8TB
Take the JavaScript code out and add it separately as you did for the initial calendar field.
Jul 4 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: EmmettPower | last post by:
Hi, I have a form which includes a field 'number'. When 'number' is changed additional fields ('item_0', etc) are generated on the form using 'onchange'. I want to validate the form using...
7
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
4
by: Stone Chen | last post by:
Hello, I have form that uses javascript createElement to add additional input fields to it. However, my validating script will not process new input fields because it can only find the named...
5
by: stellstarin | last post by:
I have a html where fields are created and added dynamically on the client side. I use the AppendChild() call to create fields dynamically. On submit i try to get the value for all the...
3
by: keithb | last post by:
My code dynamically adds template fields to a GridView control. Everything seems to work OK, except when updating, because I haven't found a way to reference the dynamically added textboxes....
1
by: keithb | last post by:
I have found that I must re-create dynamically added controls on every postback in order to find and access them programatically. The controls I am working with are inside a GridView control. When...
0
by: yeltsin27 | last post by:
I need some advice on handling dynamically added controls in a GridView. My app takes an uploaded CSV file containing addresses, converts it to a DataTable, databinds the DataTable to a...
5
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
Hi, I have a strange issue occurring with LinkButtons that are dynamically added to each (data) row of my DataGrid on that grid's ItemDataBound event. Each LinkButton is assigned its own event...
5
by: Nathan Sokalski | last post by:
I have a custom control that I wrote (I inherit from System.Web.UI.WebControls.CompositeControl). I dynamically add this control to my Page, but I was told that dynamically added controls do not...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.