Enter text into newly created dynamic text box

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jul 2009
Posts: 1
Reputation: indu.y is an unknown quantity at this point 
Solved Threads: 0
indu.y indu.y is offline Offline
Newbie Poster

Enter text into newly created dynamic text box

 
0
  #1
Jul 9th, 2009
hi everybody ,this is my first post..

Am creating a dynamic text box along with datepicker image.. when I enter newdate into the text box, it simply goes to previous textbox and updating the textfield. How to enter the date into the newly created text box??? And also once I complete the first row data , that row should be disabled..
Any help would be higly appreciated...
thanks
indu
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Enter text into newly created dynamic text box

 
0
  #2
Jul 11th, 2009
Try this :

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="utf-8" standalone="no"?>
  2. <?xml-stylesheet type="text/css" href="#cssl21" media="screen"?>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  5. <html id="xhtml10S" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  6. <head profile="http://www.w3.org/2005/10/profile">
  7. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  8. <meta http-equiv="Window-Target" content="_top" />
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  10. <meta http-equiv="Content-Style-Type" content="text/css" />
  11. <meta http-equiv="Content-Script-Type" content="text/javascript" />
  12. <title>Free Live Help!</title>
  13. <style id="ccsl21" type="text/css" media="screen">
  14. /* <![CDATA[ */
  15. form {
  16. padding : 1em;
  17. margin : 0 0 0 1em;
  18. border : 1px solid #ccc; }
  19.  
  20. input[type="button"], input {
  21. border : thin solid #ccc;
  22. display : block;
  23. background-image : none;
  24. background-color : #fff;
  25. color : #696969;
  26. vertical-align : middle;
  27. height : 22px; }
  28.  
  29. input[type="text"] {
  30. letter-spacing : 3px;
  31. color : #365d95; }
  32.  
  33. label { color : #808080; }
  34.  
  35. table { border : none; border-collapse : collapse; }
  36. td { padding-right : 1em; width auto; }
  37. .borderL { border-left : 1px solid #ccc; }
  38. /* ]]> */
  39. </style>
  40. <script type="text/javascript">
  41. // <![CDATA[
  42. var counter = 1;
  43. var modern = Boolean( document.getElementById );
  44. var ie = Boolean( document.all && !modern );
  45. var disable = function() {
  46. var num = parseInt(this.id.match(/\d+/i)[ 0 ]);
  47. var previous = (( modern ) ? document.getElementById( "txt" + (( num ) - 1 )) : document.all[ "txt" + (( num ) - 1 ) ] );
  48. previous.value = this.value;
  49. this.disabled = 1;
  50. create();
  51. };
  52. var create = function() {
  53. var now = new Date();
  54. var dateObj = [ " January ", " February ", " March ", " April ", " May ", " June ", " July ", " August ", " September ", " October ", " November ", " December " ][now.getMonth()] + (( now.getDate() < 10 ) ? "0" : "" ) + now.getDate() + ", " + now.getFullYear();
  55. var field;
  56. var labels;
  57. var fieldTxt;
  58. var table = (( modern ) ? document.getElementById("table") : (( ie ) ? document.all[ "table" ] : undefined ));
  59. if ( table ) {
  60.  
  61. var $row = table.rows;
  62. var cLen = $row[0].cells.length;
  63. try {
  64. if ( document.createElement ) {
  65. labels = document.createElement("label")
  66. var textLabel = document.createTextNode( "TextField #" + (( counter ) + 1 ));
  67. labels.appendChild( textLabel );
  68. field = document.createElement("input");
  69. field.id = "txt" + counter;
  70. field.name = "txt" + counter;
  71. field.type = "text";
  72. field.size = 30;
  73. field.value = dateObj;
  74. field.onchange = disable;
  75. table.insertRow( counter );
  76. for ( var i = 0; i < cLen; i++ ) {
  77. $row[counter].insertCell( i );
  78. $row[counter].cells( i ).appendChild((( i < 1 ) ? labels : (( i < 2 ) ? field : null )));
  79. }
  80. }
  81. } catch( e ) {
  82. field = "unable to create object, please upgrade your browser!";
  83. alert((( e.description ) ? e.description : (( e.message ) ? e.message : field )));
  84. return;
  85. } ++counter;
  86. }
  87. };
  88. // ]]>
  89. </script>
  90. </head>
  91. <body>
  92. <div id="main">
  93. <form id="form1" action="#" method="post" onsubmit="return false;">
  94. <h3 style="margin-top : 0; color : #808080;">JAVASCRIPT LIVE DEMO!</h3>
  95. <table id="table" frame="void" rules="none" summary="JavaScript Demo :: Creating Dynamic field">
  96. <tr><td><label for="txt0">TextField #1</label></td>
  97. <td><input type="text" id="txt0" name="txt0" value="" disabled="disabled" size="30" /></td>
  98. <td><input type="button" id="btn0" name="btn0" value="- Add Field -" onclick="create();" /></td></tr>
  99. </table>
  100. </form>
  101. </div>
  102. </body>
  103. </html>
Last edited by essential; Jul 11th, 2009 at 6:24 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC