<h4> Tambah Mata Kuliah </h4>
<form method=post action=?menu=create_makul>
<table border=1>
<tr>
<td> ID Mata Kuliah </td>
<td> : </td>
<td>
<?php
// Koneksi
//mysql_connect("localhost","root","");
//mysql_select_db("db_ebsof");
include "koneksi/koneksi.php";
$result = mysql_query("select * from mak1");
$jsArray = "var prdName = new Array();\n";
echo '<select name="prdId" onchange="changeValue(this.value)">';
echo '<option>-------</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['id_makul'] . '">' . $row['id_makul'] . '</option>';
$jsArray .= "prdName['" . $row['id_makul'] . "'] = {name:'" . addslashes($row['makul']) . "',desc:'".addslashes($row['sks'])."'};\n";
}
echo '</select>' ;
echo $makul;
?>
</td>
</td>
</tr>
<tr>
<td> Mata Kuliah </td>
<td> : </td>
<td> <input type="text" name="makul" id="makul"/> </td>
</tr>
</td>
</tr>
<tr>
<td> SKS </td>
<td> : </td>
<td> <input type="text" name="sks" id="sks"/> </td>
</tr>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('makul').value = prdName[id].name;
document.getElementById('sks').value = prdName[id].desc;
};
</script>
<tr>
<td> Hari </td>
<td> : </td>
<td> <input type=text name=hari maxlength=100> </td>
</tr>
<tr>
<td> Jam Tayang </td>
<td> : </td>
<?
$gula=date('H:i');
$gula1=time('h:m:s');
?>
<td> <input type=text name=gula value= <?php echo "$gula"; ?>></td>
</tr>
<tr>
<td> Pengajar </td>
<td> : </td>
<td> <select name=id_pengajar>
<?php
$makul = $_GET['makul'];
include "koneksi/koneksi.php";
$sql = mysql_query("select nip from mak where makul='$makul' order by nip");
while ($data = mysql_fetch_array($sql)){
echo "<option value='$data[nip]'> $data[nip] </option>";
}
?>
</select>
</td>
</tr>
<tr>
<td colspan=3> <input type=submit value=Simpan> <input type=submit value=Batal onClick=history.back()> </td>
</tr>
</table>
</form>
<?php
$id = $_GET['id'];
include "koneksi/koneksi.php";
$query = mysql_query("select * from mak where id_makul='$id'");
echo '<select name="id_pengajar">';
while($data = mysql_fetch_array($query)){
$pengajar = mysql_fetch_array(mysql_query("select * from pengajar where id_pengajar='".$data['id_pengajar']."'"));
echo '<option value="'.$data['id_pengajar'].'">'.$pengajar['nama-pengajar'].'</option>';
}
echo '</select>';
?>
<h4> Tambah Mata Kuliah </h4>
<form method=post action=?menu=create_makul>
<table border=1>
<tr>
<td> ID Mata Kuliah </td>
<td> : </td>
<td>
<?php
// Koneksi
//mysql_connect("localhost","root","");
//mysql_select_db("db_ebsof");
include "koneksi/koneksi.php";
$result = mysql_query("select * from mak1");
$jsArray = "var prdName = new Array();\n";
echo '<select name="prdId" onchange="changeValue(this.value)">';
echo '<option>-------</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['id_makul'] . '">' . $row['id_makul'] . '</option>';
$jsArray .= "prdName['" . $row['id_makul'] . "'] = {name:'" . addslashes($row['makul']) . "',desc:'".addslashes($row['sks'])."'};\n";
}
echo '</select>' ;
echo $makul;
?>
</td>
</td>
</tr>
<tr>
<td> Mata Kuliah </td>
<td> : </td>
<td> <input type="text" name="makul" id="makul"/> </td>
</tr>
</td>
</tr>
<tr>
<td> SKS </td>
<td> : </td>
<td> <input type="text" name="sks" id="sks"/> </td>
</tr>
<!-- tambah jquery dari google cdn atau download di jquery.com
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('makul').value = prdName[id].name;
document.getElementById('sks').value = prdName[id].desc;
$('#select-pengajar').load('get_pengajar.php?id='+id);
}
</script>
<tr>
<td> Hari </td>
<td> : </td>
<td> <input type=text name=hari maxlength=100> </td>
</tr>
<tr>
<td> Jam Tayang </td>
<td> : </td>
<?
$gula=date('H:i');
$gula1=time('h:m:s');
?>
<td> <input type=text name=gula value= <?php echo "$gula"; ?>></td>
</tr>
<tr>
<td> Pengajar </td>
<td> : </td>
<td id="select-pengajar">
<select name="id_pengajar"></select>
</td>
</tr>
<tr>
<td colspan=3> <input type=submit value=Simpan> <input type=submit value=Batal onClick=history.back()> </td>
</tr>
</table>
</form>
<h4> Tambah Mata Kuliah </h4>
<form method=post action=?menu=create_makul>
<table border=1>
<tr>
<td> ID Mata Kuliah </td>
<td> : </td>
<td>
<?php
// Koneksi
//mysql_connect("localhost","root","");
//mysql_select_db("db_ebsof");
include "koneksi/koneksi.php";
$result = mysql_query("select * from mak1");
$jsArray = "var prdName = new Array();\n";
echo '<select name="prdId" onchange="changeValue(this.value)">';
echo '<option>-------</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['id_makul'] . '">' . $row['id_makul'] . '</option>';
// $jsArray .= "prdName['" . $row['id_makul'] . "'] = {name:'" . addslashes($row['makul']) . "',desc1:'".addslashes($row['id_makul'])."',desc:'".addslashes($row['sks'])."'};\n";
$jsArray .= "prdName['" . $row['id_makul'] . "'] = {name:'" . addslashes($row['makul']) . "',desc:'".addslashes($row['sks'])."'};\n";
}
echo '</select>' ;
//echo $makul;
?>
</td>
</td>
</tr>
<tr>
<td> Mata Kuliah </td>
<td> : </td>
<td> <input type="text" name="makul" id="makul"/> </td>
</tr>
</td>
</tr>
<tr>
<td> SKS </td>
<td> : </td>
<td> <input type="text" name="sks" id="sks"/> </td>
</tr>
<input type=hidden name="id_makul" id="id_makul"/>
<script language="javascript" src="jquery-1.9.1.min"></script>
<script type="text/javascript">
//<script language="javascript" src="js/jquery-1.9.1.min.js">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('makul').value = prdName[id].name;
document.getElementById('sks').value = prdName[id].desc;
$('#select-pengajar').load('get_pengajar.php?id='+id);
//document.getElementById('id_makul').value = prdName[id].desc1;
};
</script>
<tr>
<td> Hari </td>
<td> : </td>
<td> <input type=text name=hari maxlength=100> </td>
</tr>
<tr>
<td> Jam Tayang </td>
<td> : </td>
<?
$gula=date('H:i');
$gula1=time('h:m:s');
?>
<td> <input type=text name=gula value= <?php echo "$gula"; ?>></td>
<tr>
<td> Pengajar </td>
<td> : </td>
<td id="select-pengajar">
<select name="id_pengajar"></select>
</td>
</tr>
<tr>
<td colspan=3> <input type=submit value=Simpan> <input type=submit value=Batal onClick=history.back()> </td>
</tr>
</table>
</form>