datepicker not working on edit form

datepicker not working on edit form

i have got 2 form add and edit form. datepicker working on my add form but not working edit form where is the problem (:. i cant find. 
this is my add form 
  1. <?php
  2. /* 
  3.  NEW.PHP
  4.  Allows user to create a new entry in the database
  5. */
  6.  
  7.  // creates the new record form
  8.  // since this form is used multiple times in this file, I have made it a function that is easily reusable
  9.  function renderForm($adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum, $sadi, $telefon, $adres, $error)
  10.  {
  11.  ?>
  12.  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  13.  <html>
  14.  <head>
  15.  <title>New Record</title>
  16.  
  17.  
  18.      <script type="text/javascript">

  19. var Event = {
  20. add: function(obj,type,fn) {
  21. if (obj.attachEvent) {
  22. obj['e'+type+fn] = fn;
  23. obj[type+fn] = function() { obj['e'+type+fn](window.event); }
  24. obj.attachEvent('on'+type,obj[type+fn]);
  25. } else
  26. obj.addEventListener(type,fn,false);
  27. },
  28. remove: function(obj,type,fn) {
  29. if (obj.detachEvent) {
  30. obj.detachEvent('on'+type,obj[type+fn]);
  31. obj[type+fn] = null;
  32. } else
  33. obj.removeEventListener(type,fn,false);
  34. }
  35. }

  36. function $() {
  37. var elements = new Array();
  38. for (var i=0;i<arguments.length;i++) {
  39. var element = arguments[i];
  40. if (typeof element == 'string') element = document.getElementById(element);
  41. if (arguments.length == 1) return element;
  42. elements.push(element);
  43. }
  44. return elements;
  45. }

  46. String.prototype.trim = function() {
  47. return this.replace(/^\s+|\s+$/,"");
  48. }

  49. function addClassName(el,className) {
  50. removeClassName(el,className);
  51. el.className = (el.className + " " + className).trim();
  52. }

  53. function removeClassName(el,className) {
  54. el.className = el.className.replace(className,"").trim();
  55. }

  56. var ZebraTable = {
  57. bgcolor: '',
  58. classname: '',
  59. stripe: function(el) {
  60. if (!$(el)) return;
  61. var rows = $(el).getElementsByTagName('tr');
  62. for (var i=1,len=rows.length;i<len;i++) {
  63. if (i % 2 == 0) rows[i].className = 'alt';
  64. Event.add(rows[i],'mouseover',function() { ZebraTable.mouseover(this); });
  65. Event.add(rows[i],'mouseout',function() { ZebraTable.mouseout(this); });
  66. }
  67. },
  68. mouseover: function(row) {
  69. this.bgcolor = row.style.backgroundColor;
  70. this.classname = row.className;
  71. addClassName(row,'over');
  72. },
  73. mouseout: function(row) {
  74. removeClassName(row,'over');
  75. addClassName(row,this.classname);
  76. row.style.backgroundColor = this.bgcolor;
  77. }
  78. }

  79. window.onload = function() {
  80. ZebraTable.stripe('mytable');
  81. }

  82. </script>
  83. <link rel="stylesheet" href="metro/css/jquery-ui-1.8.16.custom.css" />
  84. <script src="metro/jquery-1.6.2.min.js"></script>
  85. <script src="metro/ui/jquery.ui.core.js"></script>
  86. <script src="metro/ui/jquery.ui.widget.js"></script>
  87. <script src="metro/ui/jquery.ui.datepicker.js"></script>
  88.   <script src="metro/ui/i18n/jquery.ui.datepicker-tr.js"></script>

  89.   <script>
  90.   $(document).ready(function() {
  91. $.datepicker.formatDate('yyyy-mm-dd');
  92. $("#dogum").datepicker();
  93.   });
  94.   </script>
  95.  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  96.  
  97.  <link rel="stylesheet" href="css/css3-buttons.css" type="text/css">
  98.  
  99.  <link href="css/zebra2.css" rel="stylesheet" type="text/css">
  100.  </head>
  101. <body>
  102.  <?php 
  103.  // if there are any errors, display them
  104.  if ($error != '')
  105.  {
  106.  echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
  107.  }
  108.  ?>
  109.  

  110. <form action="" method="post">
  111.   <div>
  112.  
  113.  <table width="200" border="0" cellpadding='10' id="mytable" >
  114.   
  115.    <tr>
  116.      <th colspan="2"><center><br>
  117.      Yeni Kayıt
  118.      </center><BR></th>
  119.      </tr>
  120.    <tr>
  121.      <td width="50">Hasta Adı *</td>
  122.      <td width="150">
  123.      <label for="adi"></label>
  124.      <input name="adi" type="text" id="adi" value="<?php echo $adi; ?>"></td>
  125.    </tr>
  126.    <tr>
  127.      <td>Türü</td>
  128.      <td><label for="turu"></label>
  129.        <select name="turu" id="turu" style=" width: 172px;">
  130.          <option value="1">Köpek</option>
  131.          <option value="2">Kedi</option>
  132.        </select></td>
  133.      </tr>
  134.    <tr>
  135.      <td>Cinsi</td>
  136.      <td><label for="cinsi"></label>
  137.        <input name="cinsi" type="text" id="cinsi" value="<?php echo $cinsi; ?>"></td>
  138.      </tr>
  139.    <tr>
  140.      <td>Cinsiyet</td>
  141.      <td><label for="cinsiyet"></label>
  142.        <input name="cinsiyet" type="text" id="cinsiyet" value="<?php echo $cinsiyet; ?>"></td>
  143.      </tr>
  144.    <tr>
  145.      <td>Rengi</td>
  146.      <td><label for="rengi"></label>
  147.        <input name="rengi" type="text" id="rengi" value="<?php echo $rengi; ?>"></tsd>
  148.      </tr>
  149.    <tr>
  150.      <td>Doğum Tarihi</td>
  151.      <td><label for="dogum"></label>
  152.        <input name="dogum" type="text" id="dogum" value="<?php echo $dogum; ?>"></td>
  153.      </tr>
  154.    <tr>
  155.      <td height="30">Hasta Sahibi*</td>
  156.      <td><label for="sadi"></label>
  157.        <input name="sadi" type="text" id="sadi" value="<?php echo $sadi; ?>"></td>
  158.    </tr>
  159.    <tr>
  160.      <td>Telefon</td>
  161.      <td><label for="telefon"></label>
  162.        <input name="telefon" type="text" id="telefon" value="<?php echo $telefon; ?>"></td>
  163.    </tr>
  164.    <tr>
  165.      <td>Adres</td>
  166.      <td><label for="adres"></label>
  167.        <textarea name="adres" id="adres"><?php echo $adres; ?></textarea></td>
  168.    </tr>
  169.  </table>
  170.  <p>*Doldurulması gerekli alanlar. </p>
  171.  <button class="action blue" type="submit" name="submit" value="Submit"><span class="label">Kaydet</span></button>
  172.  
  173. <?php 
  174. //<button class="action red"><span class="label">Upload</span></button>
  175. //<button class="action green"><span class="label">üğişçöı</span></button>
  176. ?>




  177. </a>
  178.  </div>
  179.  </form>
  180.  <a href="hastalar.php">
  181. <button class="action"><span class="label">iptal</span></button>
  182. <br><br><br>
  183.  </body>
  184.  </html>
  185. <?php
  186. }
  187.  
  188.  
  189.  

  190.  // connect to the database
  191.  include('connect-db.php');
  192.  
  193.  // check if the form has been submitted. If it has, start to process the form and save it to the database
  194.  if (isset($_POST['submit']))
  195.  { 
  196.  // get form data, making sure it is valid
  197.  $adi = mysql_real_escape_string(htmlspecialchars($_POST['adi']));
  198.  $turu  = mysql_real_escape_string(htmlspecialchars($_POST['turu']));
  199.  $cinsi  = mysql_real_escape_string(htmlspecialchars($_POST['cinsi']));
  200.  $cinsiyet  = mysql_real_escape_string(htmlspecialchars($_POST['cinsiyet']));
  201.  $rengi = mysql_real_escape_string(htmlspecialchars($_POST['rengi']));
  202.  $dogum  = mysql_real_escape_string(htmlspecialchars($_POST['dogum']));
  203.  $sadi  = mysql_real_escape_string(htmlspecialchars($_POST['sadi']));
  204.  $telefon  = mysql_real_escape_string(htmlspecialchars($_POST['telefon']));
  205.  $adres = mysql_real_escape_string(htmlspecialchars($_POST['adres']));
  206.  // check to make sure both fields are entered
  207.  if ($adi == '' || $sadi == '')
  208.  {
  209.  // generate error message
  210.  $error = 'HATA  Gerekli alanları doldurunuz...';
  211.  
  212.  // if either field is blank, display the form again
  213.  renderForm($adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum, $sadi, $telefon, $adres, $error);
  214.  }
  215.  else
  216.  {
  217. $dogum1  = date("Y-m-d",strtotime($dogum)) ;
  218.  // save the data to the database
  219.  mysql_query("INSERT players SET adi='$adi', turu='$turu', cinsi='$cinsi', cinsiyet='$cinsiyet', rengi='$rengi', dogum='$dogum1', sadi='$sadi', telefon='$telefon', adres='$adres'")
  220.  or die(mysql_error()); 
  221.  $musteriid = mysql_insert_id();
  222.  // once saved, redirect back to the view page
  223.  if ($turu == '1')
  224.  {  header("Location: kopekasi.php?id=$musteriid"); 
  225.  }
  226.  else
  227.  {  header("Location: kediasi.php?id=$musteriid"); 
  228.  }
  229.  }
  230.  }
  231.  else
  232.  // if the form hasn't been submitted, display the form
  233.  {
  234.  renderForm('','','','','','','','','','');
  235.  }
datepicker is working...
but this is my edit form

  1. <?php
  2. /* 
  3.  EDIT.PHP
  4.  Allows user to edit specific entry in database
  5. */

  6.  // creates the edit record form
  7.  // since this form is used multiple times in this file, I have made it a function that is easily reusable
  8.  function renderForm($id, $adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum, $sadi, $telefon, $adres, $error)
  9.  {
  10.  ?>
  11.  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  12.  <html>
  13.  <head>
  14.  <title>Edit Record</title>
  15.  <link rel="stylesheet" href="metro/css/jquery-ui-1.8.16.custom.css" />
  16. <script src="js/development-bundle/jquery-1.8.0.js"></script>
  17. <script src="metro/ui/jquery.ui.core.js"></script>
  18. <script src="metro/ui/jquery.ui.widget.js"></script>
  19. <script src="metro/ui/jquery.ui.datepicker.js"></script>
  20.   <script src="metro/ui/i18n/jquery.ui.datepicker-tr.js"></script>

  21.   <script>
  22.  $('#dogum').DatePicker({
  23. format:'m/d/Y',
  24.     
  25. });

  26.   </script>
  27.   <script type="text/javascript">

  28. var Event = {
  29. add: function(obj,type,fn) {
  30. if (obj.attachEvent) {
  31. obj['e'+type+fn] = fn;
  32. obj[type+fn] = function() { obj['e'+type+fn](window.event); }
  33. obj.attachEvent('on'+type,obj[type+fn]);
  34. } else
  35. obj.addEventListener(type,fn,false);
  36. },
  37. remove: function(obj,type,fn) {
  38. if (obj.detachEvent) {
  39. obj.detachEvent('on'+type,obj[type+fn]);
  40. obj[type+fn] = null;
  41. } else
  42. obj.removeEventListener(type,fn,false);
  43. }
  44. }

  45. function $() {
  46. var elements = new Array();
  47. for (var i=0;i<arguments.length;i++) {
  48. var element = arguments[i];
  49. if (typeof element == 'string') element = document.getElementById(element);
  50. if (arguments.length == 1) return element;
  51. elements.push(element);
  52. }
  53. return elements;
  54. }

  55. String.prototype.trim = function() {
  56. return this.replace(/^\s+|\s+$/,"");
  57. }

  58. function addClassName(el,className) {
  59. removeClassName(el,className);
  60. el.className = (el.className + " " + className).trim();
  61. }

  62. function removeClassName(el,className) {
  63. el.className = el.className.replace(className,"").trim();
  64. }

  65. var ZebraTable = {
  66. bgcolor: '',
  67. classname: '',
  68. stripe: function(el) {
  69. if (!$(el)) return;
  70. var rows = $(el).getElementsByTagName('tr');
  71. for (var i=1,len=rows.length;i<len;i++) {
  72. if (i % 2 == 0) rows[i].className = 'alt';
  73. Event.add(rows[i],'mouseover',function() { ZebraTable.mouseover(this); });
  74. Event.add(rows[i],'mouseout',function() { ZebraTable.mouseout(this); });
  75. }
  76. },
  77. mouseover: function(row) {
  78. this.bgcolor = row.style.backgroundColor;
  79. this.classname = row.className;
  80. addClassName(row,'over');
  81. },
  82. mouseout: function(row) {
  83. removeClassName(row,'over');
  84. addClassName(row,this.classname);
  85. row.style.backgroundColor = this.bgcolor;
  86. }
  87. }

  88. window.onload = function() {
  89. ZebraTable.stripe('mytable');
  90. }

  91. </script>
  92.  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  93.  
  94.  <link rel="stylesheet" href="css/css3-buttons.css" type="text/css">
  95.  
  96.  <link href="css/zebra2.css" rel="stylesheet" type="text/css">
  97.  </head>
  98.  <body>
  99.  <?php 
  100.  // if there are any errors, display them
  101.  if ($error != '')
  102.  {
  103.  echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
  104.  }
  105.  ?> 
  106.  
  107.  <form action="" method="post">
  108.    <div>
  109.    
  110.  <table width="200" border="0" cellpadding='10' id="mytable" >
  111.   
  112.    <tr>
  113.      <th colspan="2"><center><br>
  114.      Kayıt Düzenle 
  115.          
  116.          <?php  echo $id; ?><input type="hidden" name="id" value="<?php echo $id; ?>"/>
  117.      </center><BR></th>
  118.      </tr>
  119.    <tr>
  120.      <td width="50">Hasta Adı *</td>
  121.      <td width="150">
  122.      <label for="adi"></label>
  123.      <input name="adi" type="text" id="adi" value="<?php echo $adi; ?>"></td>
  124.    </tr>
  125.    <tr>
  126.      <td>Türü</td>
  127.      <td><label for="turu"></label>
  128.        <input name="turu" type="text" id="turu" value="<?php echo $turu; ?>"></td>
  129.      </tr>
  130.    <tr>
  131.      <td>Cinsi</td>
  132.      <td><label for="cinsi"></label>
  133.        <input name="cinsi" type="text" id="cinsi" value="<?php echo $cinsi; ?>"></td>
  134.      </tr>
  135.    <tr>
  136.      <td>Cinsiyet</td>
  137.      <td><label for="cinsiyet"></label>
  138.        <input name="cinsiyet" type="text" id="cinsiyet" value="<?php echo $cinsiyet; ?>"></td>
  139.      </tr>
  140.    <tr>
  141.      <td>Rengi</td>
  142.      <td><label for="rengi"></label>
  143.        <input name="rengi" type="text" id="rengi" value="<?php echo $rengi; ?>"></td>
  144.      </tr>
  145.    <tr>
  146.      <td>Doğum Tarihi</td>
  147.      <td><label for="dogum1"></label>
  148.        <input name="dogum" type="text" id="dogum" value="<?php echo $dogum; ?>"></td>
  149.      </tr>
  150.    <tr>
  151.      <td height="30">Hasta Sahibi*</td>
  152.      <td><label for="sadi"></label>
  153.        <input name="sadi" type="text" id="sadi" value="<?php echo $sadi; ?>"></td>
  154.    </tr>
  155.    <tr>
  156.      <td>Telefon</td>
  157.      <td><label for="telefon"></label>
  158.        <input name="telefon" type="text" id="telefon" value="<?php echo $telefon; ?>"></td>
  159.    </tr>
  160.    <tr>
  161.      <td>Adres</td>
  162.      <td><label for="adres"></label>
  163.        <textarea name="adres" rows="3" id="adres"><?php echo $adres; ?></textarea></td>
  164.    </tr>
  165.  </table>
  166.  
  167.  <p>* Doldurulması gerekli alanlar.</p>
  168.  <button class="action blue" type="submit" name="submit" value="Submit"><span class="label">Düzelt</span></button>
  169.  </div>
  170.  </form>  <a href="hastalar.php">
  171. <button class="action"><span class="label">iptal</span></button>
  172.  </body>
  173.  </html> 
  174.  <?php
  175.  }



  176.  // connect to the database
  177.  include('connect-db.php');
  178.  
  179.  // check if the form has been submitted. If it has, process the form and save it to the database
  180.  if (isset($_POST['submit']))
  181.  { 
  182.  // confirm that the 'id' value is a valid integer before getting the form data
  183.  if (is_numeric($_POST['id']))
  184.  {
  185.  // get form data, making sure it is valid
  186. // $id = mysql_real_escape_string(htmlspecialchars($_POST['id']));
  187.  $id = $_POST['id'];
  188.  $adi = mysql_real_escape_string(htmlspecialchars($_POST['adi']));
  189.  $turu  = mysql_real_escape_string(htmlspecialchars($_POST['turu']));
  190.  $cinsi  = mysql_real_escape_string(htmlspecialchars($_POST['cinsi']));
  191.  $cinsiyet  = mysql_real_escape_string(htmlspecialchars($_POST['cinsiyet']));
  192.  $rengi = mysql_real_escape_string(htmlspecialchars($_POST['rengi']));
  193.  $dogum  = mysql_real_escape_string(htmlspecialchars($_POST['dogum']));
  194.  $sadi  = mysql_real_escape_string(htmlspecialchars($_POST['sadi']));
  195.  $telefon  = mysql_real_escape_string(htmlspecialchars($_POST['telefon']));
  196.  $adres = mysql_real_escape_string(htmlspecialchars($_POST['adres']));
  197.   $dogum1  = date("Y-m-d",strtotime($dogum)) ;
  198.  // check that firstname/lastname fields are both filled in
  199. if ($adi == '' || $sadi == '')
  200.  {
  201.  // generate error message
  202.  $error = 'HATA  Gerekli alanları doldurunuz...';
  203.  
  204.  //error, display form
  205.  renderForm($id, $adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum1, $sadi, $telefon, $adres, $error);
  206.  }
  207.  else
  208.  {
  209.  // save the data to the database
  210.  mysql_query("UPDATE players SET adi='$adi', turu='$turu', cinsi='$cinsi', cinsiyet='$cinsiyet', rengi='$rengi', dogum='$dogum1', sadi='$sadi', telefon='$telefon', adres='$adres' WHERE id='$id'")
  211.  or die(mysql_error()); 
  212.  
  213.  // once saved, redirect back to the view page
  214.  header("Location: hastalar.php"); 
  215.  }
  216.  }
  217.  else
  218.  {
  219.  // if the 'id' isn't valid, display an error
  220.  echo 'Yanlış bişeyler var!';
  221.  }
  222.  }
  223.  else
  224.  // if the form hasn't been submitted, get the data from the db and display the form
  225.  {
  226.  
  227.  // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
  228.  if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
  229.  {
  230.  // query db
  231.  $id = $_GET['id'];
  232.  $result = mysql_query("SELECT * FROM players WHERE id=$id")
  233.  or die(mysql_error()); 
  234.  $row = mysql_fetch_array($result);
  235.  
  236.  // check that the 'id' matches up with a row in the databse
  237.  if($row)
  238.  {
  239.  
  240.  // get data from db
  241. // $id = $row['id'];
  242.  $adi = $row['adi'];
  243.  $turu  = $row['turu'];
  244.  $cinsi  = $row['cinsi'];
  245.  $cinsiyet  = $row['cinsiyet'];
  246.  $rengi = $row['rengi'];
  247.  $dogum  = $row['dogum'];
  248.  $sadi  = $row['sadi'];
  249.  $telefon  = $row['telefon'];
  250.  $adres = $row['adres'];
  251.   $dogum1  = date("d.m.Y",strtotime($dogum)) ;
  252.  // show form
  253.  renderForm($id, $adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum1, $sadi, $telefon, $adres, '');
  254.  }
  255.  else
  256.  // if no match, display result
  257.  {
  258.  echo "No results!";
  259.  }
  260.  }
  261.  else
  262.  // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
  263.  {
  264.  echo 'Error!';
  265.  }
  266.  }
  267. ?>
  268.