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
- <?php
- /*
- NEW.PHP
- Allows user to create a new entry in the database
- */
-
- // creates the new record form
- // since this form is used multiple times in this file, I have made it a function that is easily reusable
- function renderForm($adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum, $sadi, $telefon, $adres, $error)
- {
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html>
- <head>
- <title>New Record</title>
-
-
- <script type="text/javascript">
- var Event = {
- add: function(obj,type,fn) {
- if (obj.attachEvent) {
- obj['e'+type+fn] = fn;
- obj[type+fn] = function() { obj['e'+type+fn](window.event); }
- obj.attachEvent('on'+type,obj[type+fn]);
- } else
- obj.addEventListener(type,fn,false);
- },
- remove: function(obj,type,fn) {
- if (obj.detachEvent) {
- obj.detachEvent('on'+type,obj[type+fn]);
- obj[type+fn] = null;
- } else
- obj.removeEventListener(type,fn,false);
- }
- }
- function $() {
- var elements = new Array();
- for (var i=0;i<arguments.length;i++) {
- var element = arguments[i];
- if (typeof element == 'string') element = document.getElementById(element);
- if (arguments.length == 1) return element;
- elements.push(element);
- }
- return elements;
- }
- String.prototype.trim = function() {
- return this.replace(/^\s+|\s+$/,"");
- }
- function addClassName(el,className) {
- removeClassName(el,className);
- el.className = (el.className + " " + className).trim();
- }
- function removeClassName(el,className) {
- el.className = el.className.replace(className,"").trim();
- }
- var ZebraTable = {
- bgcolor: '',
- classname: '',
- stripe: function(el) {
- if (!$(el)) return;
- var rows = $(el).getElementsByTagName('tr');
- for (var i=1,len=rows.length;i<len;i++) {
- if (i % 2 == 0) rows[i].className = 'alt';
- Event.add(rows[i],'mouseover',function() { ZebraTable.mouseover(this); });
- Event.add(rows[i],'mouseout',function() { ZebraTable.mouseout(this); });
- }
- },
- mouseover: function(row) {
- this.bgcolor = row.style.backgroundColor;
- this.classname = row.className;
- addClassName(row,'over');
- },
- mouseout: function(row) {
- removeClassName(row,'over');
- addClassName(row,this.classname);
- row.style.backgroundColor = this.bgcolor;
- }
- }
- window.onload = function() {
- ZebraTable.stripe('mytable');
- }
- </script>
- <link rel="stylesheet" href="metro/css/jquery-ui-1.8.16.custom.css" />
- <script src="metro/jquery-1.6.2.min.js"></script>
- <script src="metro/ui/jquery.ui.core.js"></script>
- <script src="metro/ui/jquery.ui.widget.js"></script>
- <script src="metro/ui/jquery.ui.datepicker.js"></script>
- <script src="metro/ui/i18n/jquery.ui.datepicker-tr.js"></script>
- <script>
- $(document).ready(function() {
- $.datepicker.formatDate('yyyy-mm-dd');
- $("#dogum").datepicker();
- });
- </script>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-
- <link rel="stylesheet" href="css/css3-buttons.css" type="text/css">
-
- <link href="css/zebra2.css" rel="stylesheet" type="text/css">
- </head>
- <body>
- <?php
- // if there are any errors, display them
- if ($error != '')
- {
- echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
- }
- ?>
-
- <form action="" method="post">
- <div>
-
- <table width="200" border="0" cellpadding='10' id="mytable" >
-
- <tr>
- <th colspan="2"><center><br>
- Yeni Kayıt
- </center><BR></th>
- </tr>
- <tr>
- <td width="50">Hasta Adı *</td>
- <td width="150">
- <label for="adi"></label>
- <input name="adi" type="text" id="adi" value="<?php echo $adi; ?>"></td>
- </tr>
- <tr>
- <td>Türü</td>
- <td><label for="turu"></label>
- <select name="turu" id="turu" style=" width: 172px;">
- <option value="1">Köpek</option>
- <option value="2">Kedi</option>
- </select></td>
- </tr>
- <tr>
- <td>Cinsi</td>
- <td><label for="cinsi"></label>
- <input name="cinsi" type="text" id="cinsi" value="<?php echo $cinsi; ?>"></td>
- </tr>
- <tr>
- <td>Cinsiyet</td>
- <td><label for="cinsiyet"></label>
- <input name="cinsiyet" type="text" id="cinsiyet" value="<?php echo $cinsiyet; ?>"></td>
- </tr>
- <tr>
- <td>Rengi</td>
- <td><label for="rengi"></label>
- <input name="rengi" type="text" id="rengi" value="<?php echo $rengi; ?>"></tsd>
- </tr>
- <tr>
- <td>Doğum Tarihi</td>
- <td><label for="dogum"></label>
- <input name="dogum" type="text" id="dogum" value="<?php echo $dogum; ?>"></td>
- </tr>
- <tr>
- <td height="30">Hasta Sahibi*</td>
- <td><label for="sadi"></label>
- <input name="sadi" type="text" id="sadi" value="<?php echo $sadi; ?>"></td>
- </tr>
- <tr>
- <td>Telefon</td>
- <td><label for="telefon"></label>
- <input name="telefon" type="text" id="telefon" value="<?php echo $telefon; ?>"></td>
- </tr>
- <tr>
- <td>Adres</td>
- <td><label for="adres"></label>
- <textarea name="adres" id="adres"><?php echo $adres; ?></textarea></td>
- </tr>
- </table>
- <p>*Doldurulması gerekli alanlar. </p>
- <button class="action blue" type="submit" name="submit" value="Submit"><span class="label">Kaydet</span></button>
-
- <?php
- //<button class="action red"><span class="label">Upload</span></button>
- //<button class="action green"><span class="label">üğişçöı</span></button>
- ?>
- </a>
- </div>
- </form>
- <a href="hastalar.php">
- <button class="action"><span class="label">iptal</span></button>
- <br><br><br>
- </body>
- </html>
- <?php
- }
-
-
-
- // connect to the database
- include('connect-db.php');
-
- // check if the form has been submitted. If it has, start to process the form and save it to the database
- if (isset($_POST['submit']))
- {
- // get form data, making sure it is valid
- $adi = mysql_real_escape_string(htmlspecialchars($_POST['adi']));
- $turu = mysql_real_escape_string(htmlspecialchars($_POST['turu']));
- $cinsi = mysql_real_escape_string(htmlspecialchars($_POST['cinsi']));
- $cinsiyet = mysql_real_escape_string(htmlspecialchars($_POST['cinsiyet']));
- $rengi = mysql_real_escape_string(htmlspecialchars($_POST['rengi']));
- $dogum = mysql_real_escape_string(htmlspecialchars($_POST['dogum']));
- $sadi = mysql_real_escape_string(htmlspecialchars($_POST['sadi']));
- $telefon = mysql_real_escape_string(htmlspecialchars($_POST['telefon']));
- $adres = mysql_real_escape_string(htmlspecialchars($_POST['adres']));
- // check to make sure both fields are entered
- if ($adi == '' || $sadi == '')
- {
- // generate error message
- $error = 'HATA Gerekli alanları doldurunuz...';
-
- // if either field is blank, display the form again
- renderForm($adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum, $sadi, $telefon, $adres, $error);
- }
- else
- {
- $dogum1 = date("Y-m-d",strtotime($dogum)) ;
- // save the data to the database
- mysql_query("INSERT players SET adi='$adi', turu='$turu', cinsi='$cinsi', cinsiyet='$cinsiyet', rengi='$rengi', dogum='$dogum1', sadi='$sadi', telefon='$telefon', adres='$adres'")
- or die(mysql_error());
- $musteriid = mysql_insert_id();
- // once saved, redirect back to the view page
- if ($turu == '1')
- { header("Location: kopekasi.php?id=$musteriid");
- }
- else
- { header("Location: kediasi.php?id=$musteriid");
- }
- }
- }
- else
- // if the form hasn't been submitted, display the form
- {
- renderForm('','','','','','','','','','');
- }
datepicker is working...
but this is my edit form
- <?php
- /*
- EDIT.PHP
- Allows user to edit specific entry in database
- */
- // creates the edit record form
- // since this form is used multiple times in this file, I have made it a function that is easily reusable
- function renderForm($id, $adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum, $sadi, $telefon, $adres, $error)
- {
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html>
- <head>
- <title>Edit Record</title>
- <link rel="stylesheet" href="metro/css/jquery-ui-1.8.16.custom.css" />
- <script src="js/development-bundle/jquery-1.8.0.js"></script>
- <script src="metro/ui/jquery.ui.core.js"></script>
- <script src="metro/ui/jquery.ui.widget.js"></script>
- <script src="metro/ui/jquery.ui.datepicker.js"></script>
- <script src="metro/ui/i18n/jquery.ui.datepicker-tr.js"></script>
- <script>
- $('#dogum').DatePicker({
- format:'m/d/Y',
-
- });
- </script>
- <script type="text/javascript">
- var Event = {
- add: function(obj,type,fn) {
- if (obj.attachEvent) {
- obj['e'+type+fn] = fn;
- obj[type+fn] = function() { obj['e'+type+fn](window.event); }
- obj.attachEvent('on'+type,obj[type+fn]);
- } else
- obj.addEventListener(type,fn,false);
- },
- remove: function(obj,type,fn) {
- if (obj.detachEvent) {
- obj.detachEvent('on'+type,obj[type+fn]);
- obj[type+fn] = null;
- } else
- obj.removeEventListener(type,fn,false);
- }
- }
- function $() {
- var elements = new Array();
- for (var i=0;i<arguments.length;i++) {
- var element = arguments[i];
- if (typeof element == 'string') element = document.getElementById(element);
- if (arguments.length == 1) return element;
- elements.push(element);
- }
- return elements;
- }
- String.prototype.trim = function() {
- return this.replace(/^\s+|\s+$/,"");
- }
- function addClassName(el,className) {
- removeClassName(el,className);
- el.className = (el.className + " " + className).trim();
- }
- function removeClassName(el,className) {
- el.className = el.className.replace(className,"").trim();
- }
- var ZebraTable = {
- bgcolor: '',
- classname: '',
- stripe: function(el) {
- if (!$(el)) return;
- var rows = $(el).getElementsByTagName('tr');
- for (var i=1,len=rows.length;i<len;i++) {
- if (i % 2 == 0) rows[i].className = 'alt';
- Event.add(rows[i],'mouseover',function() { ZebraTable.mouseover(this); });
- Event.add(rows[i],'mouseout',function() { ZebraTable.mouseout(this); });
- }
- },
- mouseover: function(row) {
- this.bgcolor = row.style.backgroundColor;
- this.classname = row.className;
- addClassName(row,'over');
- },
- mouseout: function(row) {
- removeClassName(row,'over');
- addClassName(row,this.classname);
- row.style.backgroundColor = this.bgcolor;
- }
- }
- window.onload = function() {
- ZebraTable.stripe('mytable');
- }
- </script>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-
- <link rel="stylesheet" href="css/css3-buttons.css" type="text/css">
-
- <link href="css/zebra2.css" rel="stylesheet" type="text/css">
- </head>
- <body>
- <?php
- // if there are any errors, display them
- if ($error != '')
- {
- echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
- }
- ?>
-
- <form action="" method="post">
- <div>
-
- <table width="200" border="0" cellpadding='10' id="mytable" >
-
- <tr>
- <th colspan="2"><center><br>
- Kayıt Düzenle
-
- <?php echo $id; ?><input type="hidden" name="id" value="<?php echo $id; ?>"/>
- </center><BR></th>
- </tr>
- <tr>
- <td width="50">Hasta Adı *</td>
- <td width="150">
- <label for="adi"></label>
- <input name="adi" type="text" id="adi" value="<?php echo $adi; ?>"></td>
- </tr>
- <tr>
- <td>Türü</td>
- <td><label for="turu"></label>
- <input name="turu" type="text" id="turu" value="<?php echo $turu; ?>"></td>
- </tr>
- <tr>
- <td>Cinsi</td>
- <td><label for="cinsi"></label>
- <input name="cinsi" type="text" id="cinsi" value="<?php echo $cinsi; ?>"></td>
- </tr>
- <tr>
- <td>Cinsiyet</td>
- <td><label for="cinsiyet"></label>
- <input name="cinsiyet" type="text" id="cinsiyet" value="<?php echo $cinsiyet; ?>"></td>
- </tr>
- <tr>
- <td>Rengi</td>
- <td><label for="rengi"></label>
- <input name="rengi" type="text" id="rengi" value="<?php echo $rengi; ?>"></td>
- </tr>
- <tr>
- <td>Doğum Tarihi</td>
- <td><label for="dogum1"></label>
- <input name="dogum" type="text" id="dogum" value="<?php echo $dogum; ?>"></td>
- </tr>
- <tr>
- <td height="30">Hasta Sahibi*</td>
- <td><label for="sadi"></label>
- <input name="sadi" type="text" id="sadi" value="<?php echo $sadi; ?>"></td>
- </tr>
- <tr>
- <td>Telefon</td>
- <td><label for="telefon"></label>
- <input name="telefon" type="text" id="telefon" value="<?php echo $telefon; ?>"></td>
- </tr>
- <tr>
- <td>Adres</td>
- <td><label for="adres"></label>
- <textarea name="adres" rows="3" id="adres"><?php echo $adres; ?></textarea></td>
- </tr>
- </table>
-
- <p>* Doldurulması gerekli alanlar.</p>
- <button class="action blue" type="submit" name="submit" value="Submit"><span class="label">Düzelt</span></button>
- </div>
- </form> <a href="hastalar.php">
- <button class="action"><span class="label">iptal</span></button>
- </body>
- </html>
- <?php
- }
- // connect to the database
- include('connect-db.php');
-
- // check if the form has been submitted. If it has, process the form and save it to the database
- if (isset($_POST['submit']))
- {
- // confirm that the 'id' value is a valid integer before getting the form data
- if (is_numeric($_POST['id']))
- {
- // get form data, making sure it is valid
- // $id = mysql_real_escape_string(htmlspecialchars($_POST['id']));
- $id = $_POST['id'];
- $adi = mysql_real_escape_string(htmlspecialchars($_POST['adi']));
- $turu = mysql_real_escape_string(htmlspecialchars($_POST['turu']));
- $cinsi = mysql_real_escape_string(htmlspecialchars($_POST['cinsi']));
- $cinsiyet = mysql_real_escape_string(htmlspecialchars($_POST['cinsiyet']));
- $rengi = mysql_real_escape_string(htmlspecialchars($_POST['rengi']));
- $dogum = mysql_real_escape_string(htmlspecialchars($_POST['dogum']));
- $sadi = mysql_real_escape_string(htmlspecialchars($_POST['sadi']));
- $telefon = mysql_real_escape_string(htmlspecialchars($_POST['telefon']));
- $adres = mysql_real_escape_string(htmlspecialchars($_POST['adres']));
- $dogum1 = date("Y-m-d",strtotime($dogum)) ;
- // check that firstname/lastname fields are both filled in
- if ($adi == '' || $sadi == '')
- {
- // generate error message
- $error = 'HATA Gerekli alanları doldurunuz...';
-
- //error, display form
- renderForm($id, $adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum1, $sadi, $telefon, $adres, $error);
- }
- else
- {
- // save the data to the database
- 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'")
- or die(mysql_error());
-
- // once saved, redirect back to the view page
- header("Location: hastalar.php");
- }
- }
- else
- {
- // if the 'id' isn't valid, display an error
- echo 'Yanlış bişeyler var!';
- }
- }
- else
- // if the form hasn't been submitted, get the data from the db and display the form
- {
-
- // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
- if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
- {
- // query db
- $id = $_GET['id'];
- $result = mysql_query("SELECT * FROM players WHERE id=$id")
- or die(mysql_error());
- $row = mysql_fetch_array($result);
-
- // check that the 'id' matches up with a row in the databse
- if($row)
- {
-
- // get data from db
- // $id = $row['id'];
- $adi = $row['adi'];
- $turu = $row['turu'];
- $cinsi = $row['cinsi'];
- $cinsiyet = $row['cinsiyet'];
- $rengi = $row['rengi'];
- $dogum = $row['dogum'];
- $sadi = $row['sadi'];
- $telefon = $row['telefon'];
- $adres = $row['adres'];
- $dogum1 = date("d.m.Y",strtotime($dogum)) ;
- // show form
- renderForm($id, $adi, $turu, $cinsi, $cinsiyet, $rengi, $dogum1, $sadi, $telefon, $adres, '');
- }
- else
- // if no match, display result
- {
- echo "No results!";
- }
- }
- else
- // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
- {
- echo 'Error!';
- }
- }
- ?>