Advertisement
GWibisono

script sebelumnya

Jun 15th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.33 KB | None | 0 0
  1. <head>
  2. <link type="text/css" href="../js/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
  3. <script type="text/javascript" src="../js/jquery-1.7.2.js"></script>
  4. <script type="text/javascript" src="../js/jquery-ui-1.8.20.cust*m.min.js"></script>
  5.  
  6. <script type="text/javascript" src="../js/jquery.validate.js"></script>
  7. <script language="javascript">
  8. $(document).ready(function()
  9. {
  10.    
  11.  
  12.     $("#kamarc").blur(function()
  13.     {
  14.         //remove all the class add the messagebox classes and start fading
  15.         $("#msgbox").removeClass().text('Checking...').fadeIn("slow");
  16.         //check the username exists or not from ajax
  17.         $.post("cek_kamar.php",{no_kamar:$(this).val() } ,function(data)
  18.         {
  19.             if(data=="no") //if username not avaiable
  20.             {
  21.                 $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
  22.                 {
  23.                 //add message and change the class of the box and start fading
  24.                 $(this).html("Kamar Sudah Di tempati").fadeTo(900,1);
  25.                 });
  26.             }
  27.             elseif(data=="yes") //if username not avaiable
  28.             {
  29.                 $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
  30.                 {
  31.                     //add message and change the class of the box and start fading
  32.                     $(this).html("Kamar Masih Kosong").fadeTo(900,1);
  33.  
  34.                 });
  35.             }
  36.         });
  37.  
  38.     });
  39.  
  40. });
  41. </script>
  42. <script>
  43. $(document).ready(function(){
  44.     $("#penghuni").validate({
  45.     rules: {
  46.     nama: {
  47.     required: true,
  48.     minlength: 3
  49.     },
  50.     pass:{
  51.     required:true,
  52.     minlength:5
  53.     },
  54.     kamarc:{
  55.  
  56.     required: if(data=="no")
  57.     },
  58.  
  59.     },
  60.     messages: {
  61.     nama: {
  62.     required: "Kolom nama harus diisi",
  63.     minlength: "Kolom nama minimal terdiri 3 karakter"
  64.     },
  65.     pass: {
  66.     required: "Kolom password harus diisi",
  67.     minlength: "Kolom password minimal terdiri 5 karakter"
  68.     },
  69.  
  70.     },
  71.     submitHandler: function(form){
  72.     $(form).ajaxSubmit({
  73.     dataType: "xml",
  74.     resetForm: true,
  75.     success: function(data){
  76.     alert("Data telah disimpan");
  77.     }
  78.     });
  79.     }
  80.     });
  81. });
  82.  
  83. $(document).ready(function()
  84. {
  85.     $("#kamar").blur(function()
  86.     {
  87.     //remove all the class add the messagebox classes and start fading
  88.     $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
  89.     //check the username exists or not from ajax
  90.     $.post("cek_kamar.php",{no_kamar:$(this).val() } ,function(data)
  91.     {
  92.     if(data=='no') //if username not avaiable
  93.     {
  94.     $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
  95.     {
  96.     //add message and change the class of the box and start fading
  97.     $(this).html('Nama Sudah Ada').addClass('messageboxerror').fadeTo(900,1);
  98.     });
  99.     }
  100.     else
  101.     {
  102.     $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
  103.     {
  104.     //add message and change the class of the box and start fading
  105.     $(this).html('Nama Tersedia ').addClass('messageboxok').fadeTo(900,1);
  106.     $(this).focus();
  107.     });
  108.  
  109.     }
  110.  
  111.     });
  112.  
  113.     });
  114.  
  115. });
  116. </script>
  117.  
  118. </head>
  119. <body>
  120.  
  121. <h2>Input Penghuni </h2>
  122. <form action="penghunisim.php" method="post" enctype="multipart/form-data" name="penghuni" id="penghuni" class="cmxForm">
  123. <table width="725" border=0>
  124. <tr>
  125. <td width="213">Nama</td>
  126. <td width="502">:
  127. <input name="nama" type="text" id="cnama" class="required" title="nama tidak boleh kosong!"></td>
  128. </tr>
  129. <tr>
  130. <td>User</td>
  131. <td>:
  132. <input name="user" type="text" id="user" class="required" title="user tidak boleh kosong!"></td>
  133. </tr>
  134. <tr>
  135. <td>Password</td>
  136. <td>:
  137. <input name="pass" type="text" id="pass" class="required" title="password harus diisi!"></td>
  138. </tr>
  139. <tr>
  140. <td>Alamat Asli</td>
  141. <td>:
  142. <textarea name="alamat" id="alamat" cols="45" rows="5"></textarea></td>
  143. </tr>
  144. <tr>
  145. <td>No.Telp</td>
  146. <td>:
  147. <input type="text" name="notelp" id="notelp"></td>
  148. </tr>
  149. <tr>
  150. <td>Kampus</td>
  151. <td>:
  152. <select name="kampus" id="kampus" class="required" title="kampus harus dipilih!">
  153. <option> </option>
  154. <?php include '../config/koneksi.php';
  155. $tampil=mysql_query("select * from kampus order by id_kampus");
  156. while($r=mysql_fetch_array($tampil)){
  157. echo "<option value=$r[id_kampus]>$r[kampus]</option>";
  158. } ?>
  159. </select></td>
  160. </tr>
  161. <tr>
  162. <td>Jurusan</td>
  163. <td>:
  164. <select name="jurusan" id="jurusan" class="required" title="jurusan wajib diisi !">
  165. <option></option>
  166. <?php include '../config/koneksi.php';
  167. $tampil=mysql_query("select * from jurusan order by kd_jurusan");
  168. while($r=mysql_fetch_array($tampil)){
  169. echo "<option value=$r[kd_jurusan]>$r[jurusan]</option>";
  170. } ?>
  171. </select></td>
  172. </tr>
  173. <tr>
  174. <td>Tgl Masuk Asrama</td>
  175. <td>:
  176. <select name="tanggal" class="required" title=" diisi!">
  177. <option> </option>
  178. <?php
  179. for($hr=1; $hr<32 ; $hr++)
  180. {
  181. echo"<option value='$hr'>$hr</option>";
  182. }
  183. ?>
  184. </select>
  185. -
  186. <select name="bulan" class="required" title="diisi dulu">
  187. <option> </option>
  188. <option value="01">Januari</option>
  189. <option value="02">Februari</option>
  190. <option value="03">Maret</option>
  191. <option value="04">April</option>
  192. <option value="05">Mei</option>
  193. <option value="06">Juni</option>
  194. <option value="07">Juli</option>
  195. <option value="08">Agustus</option>
  196. <option value="09">September</option>
  197. <option value="10">Oktober</option>
  198. <option value="11">November</option>
  199. <option value="12">Desember</option>
  200. </select>
  201. -
  202. <select name="tahun" class="required" title="diisi dulu">
  203. <option> </option>
  204. <?php
  205. $year=date("Y");
  206. for($th=2007; $th<2015; $th++)
  207. {
  208. echo" <option value='$th'>$th</option>";
  209. }
  210. ?>
  211. </select></td>
  212. </tr>
  213. <tr>
  214. <td>Tgl Masuk Kuliah</td>
  215. <td>:
  216. <select name="tanggal2" class="required" title=" diisi!">
  217. <option> </option>
  218. <?php
  219. for($hr=1; $hr<32 ; $hr++)
  220. {
  221. echo"<option value='$hr'>$hr</option>";
  222. }
  223. ?>
  224. </select>
  225. -
  226. <select name="bulan2" class="required" title="diisi dulu">
  227. <option> </option>
  228. <option value="01">Januari</option>
  229. <option value="02">Februari</option>
  230. <option value="03">Maret</option>
  231. <option value="04">April</option>
  232. <option value="05">Mei</option>
  233. <option value="06">Juni</option>
  234. <option value="07">Juli</option>
  235. <option value="08">Agustus</option>
  236. <option value="09">September</option>
  237. <option value="10">Oktober</option>
  238. <option value="11">November</option>
  239. <option value="12">Desember</option>
  240. </select>
  241. -
  242. <select name="tahun2" class="required" title="diisi dulu">
  243. <option> </option>
  244. <?php
  245. $year=date("Y");
  246. for($th=2007; $th<2015; $th++)
  247. {
  248. echo" <option value='$th'>$th</option>";
  249. }
  250. ?>
  251. </select></td>
  252. </tr>
  253. <tr>
  254. <td>Kamar</td>
  255. <td>:
  256.     <select name="kamar" id="kamarc" class="required" title="kamar diisi !">
  257.     <option></option>
  258.     <?php include '../config/koneksi.php';
  259.     $tampil=mysql_query("select * from kamar order by no_kamar");
  260.     while($r=mysql_fetch_array($tampil)){
  261.         echo "<option value=$r[no_kamar]>$r[no_kamar]</option>";
  262.     } ?>
  263.     </select>
  264.     <span id="msgbox" style="display:none"></span>
  265. </td>
  266. </tr>
  267. <tr>
  268. <td>Foto</td>
  269. <td>:
  270. <input name="foto" type="file" id="foto" class="required" title="foto wajib diisi"></td>
  271. </tr>
  272. <tr>
  273. <td>&nbsp;</td>
  274. <td><input type="submit" name="button" id="button" value="Simpan"></td>
  275. </tr>
  276. </table>
  277. <hr>
  278. </form>
  279. </div>
  280.  
  281.  
  282. </body>
  283. <h2>Data Penghuni</h2>
  284.  
  285. <table width="576" border="1">
  286.  
  287.  
  288. <tr>
  289. <td width="47" align="center"><strong>No</strong></td>
  290. <td width="96" align="center"><strong>No ID </strong></td>
  291. <td width="84" align="center"><strong>Nama</strong></td>
  292. <td width="110" align="center"><strong>No Kamar </strong></td>
  293. <td align="center" colspan="4"><strong>Aksi</strong></td>
  294. </tr>
  295. <?php
  296. include '../config/koneksi.php';
  297. $file=$_SERVER['PHP_SELF'];
  298. include "class_paging.php";
  299. $p = new Paging;
  300. $batas = 10;
  301. $posisi = $p->cariPosisi($batas);
  302.  
  303.  
  304. $sql="SELECT * from penghuni where status='penghuni' order by no_kamar limit $posisi,$batas";
  305. $qry =mysql_query($sql);
  306. $no=$posisi+1;
  307. while($r=mysql_fetch_array($qry)){
  308. $ni++;
  309. ?>
  310. <tr>
  311. <td align="center"><?php echo $ni ?>.</td>
  312. <td align="center"><?php echo $r[id_penghuni] ?></td>
  313. <td><?php echo $r[nama] ?></td>
  314. <td align="center"><?php echo $r[no_kamar] ?></td>
  315.  
  316. <td width="115" align="center"><a href="media.php?p=penghunidet&amp;id=<?php echo $r[id_penghuni] ?>">Detail</a></td>
  317. <td width="84" align="center"><a href="penghunidel.php?id=<?php echo $r[id_penghuni] ?>">Hapus</a></td>
  318. <td width="84" align="center"><a href="media.php?p=penghunieditalum&id=<?php echo $r[id_penghuni] ?>">Alumni</a></td>
  319. </tr>
  320. <?php } ?>
  321.  
  322. </table>
  323.  
  324. <?php
  325.  
  326. $jmldata = mysql_num_rows(mysql_query("SELECT * FROM penghuni"));
  327. $jmlhalaman = $p->jumlahHalaman($jmldata, $batas);
  328. $linkHalaman = $p->navHalaman($_REQUEST[halaman], $jmlhalaman);
  329. echo $linkHalaman;
  330. ?>
  331. <p>&nbsp;</p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement