<?php
if($_POST){
if(!isset($_POST['jenis_kelamin']) || !$_POST['jenis_kelamin']){
echo 'Pilih jenis kelamin';
}
}
?>
<form method="post" action="">
Jenis Kelamin:
<input type="radio" name="jenis_kelamin" value="L"/> Laki Laki
<input type="radio" name="jenis_kelamin" value="P"/> Perempuan
<input type="submit" value="save"/>
</form>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Aplikasi Pendukung Keputusan </title>
<link rel="shortcut icon" href="../images/gambar.ico" />
<link rel="stylesheet" type="text/css" href="../css/style.css" media="screen" />
<link rel="stylesheet" type="text/css" href="utbleStyl.css" />
<script type="text/javascript" src="../jscript/jquery-latest.pack.js"></script>
<script type="text/javascript">//untuk validasi radio button
function check_radio(formNilKrit){
var i;
for(i=0;i<document.forms[formNilKrit].Matriks.length;i++){
if(document.forms.[formNilKrit].Matriks[i].checked){
return(true);
}
}
alert('Anda belum memilih satupun.');
return(false);
}
</script>
</head>
<body>
<div id="wrapper">
<div id="header" class="container">
<div id="logo">
<div style="margin:130px 0 0 35px;"><h2><font color="5AD54B">Perbandingan Dengan Radio Button</font></h2></div>
</div>
</div>
<div id="menu" class="container">
<ul>
<li><a href="../index.php">home</a></li>
<li><a href="#">step 1</a></li>
<li><a href="#">step 2</a></li>
<li class="active"><a href="#">step 3</a></li>
</ul>
</div>
<div id="top-bar" class="container">
<div class="bar">
<div class="text"><marquee onmouseover="stop()" onmouseout="start()">perbandingan dengan radio button</marquee></div>
</div>
</div>
<div id="page" class="container">
<div id="content">
<div class="post">
<div class="entry">
<div class="index">
<?php
if(isset($_POST['cekAlter'])){
?>
<form method="post" name="formNilKrit" action="prioKrit.php" onsubmit="check_radio(formNilKrit)">
<?php
//bag.kriteria
$jmlKrit = $_POST['jmlKriteria']; //jml kriteria
foreach ($_POST['nmaKrit'] as $nmKrit){
$kriteria[] = $nmKrit; //isi nma kriteria kedlm array
?>
<input type="hidden" name="nmaKrit[]" value="<?php echo $nmKrit; ?>" /> <!-- menyimpan nma kriteria yang di post -->
<?php
}
?>
<input type="hidden" name="jmlKriteria" value="<?php echo $jmlKrit; ?>" /> <!-- menyimpan jml kriteria yang dipilih -->
<!--tutp bag.kriteria -->
<?php //Menyimpan jumlah kriteria yang dipilih
//Bagian alternatif
$jumlahAlter = 0;
foreach ($_POST['cekAlter'] as $idAlter){
$idAlternatif[] = $idAlter;
include "../config.php";
$sqlAlter = mysql_query("select * from alternatif where id_alter='$idAlter'");
if ($data = mysql_fetch_array($sqlAlter)){
$arrAlter[] = $data['alternatif'];
?>
<!--Menyimpan nama alternatif yang akan dipost-->
<input type="hidden" name="namaAlter[]" value="<?php echo $data['alternatif'];?>"/>
<!--Menyimpan data id utk dipost-->
<input type="hidden" name="idAlter[]" value="<?php echo $data['id_alter']; ?>" />
<?php
}
$jumlahAlter++; //Jumlah alternatif
}
?>
<input type="hidden" name="jmlAlternatif[]" value="<?php echo $jumlahAlter; ?>" />
<!-- matriks perbandingan -->
Pada tahap ini akan dilakukan perbandingan dengan skala 1-9:
<hr color="#CCCCCC" />
<table>
<?php
for ($y=1; $y<=$jmlKrit; $y++){
for ($z=$y+1; $z<=$jmlKrit; $z++){
$kriteria[$z-1] = $kriteria[$z-1];
echo
"<tr>
<td><input type='text' value='".$kriteria[$y-1]."'><input name='Matriks".($y).($z)."' type='radio' class='radiokiri' readonly='true' value='kanan'></td>
<td>
<select style='text-align:justify;' class='box' name='M".($y).($z)."'>
<option value='1'>1.Sama penting dengan</option>
<option value='2'>2.Mendekati sedikit lebih penting dari</option>
<option value='3'>3.Sedikit lebih penting dari</option>
<option value='4'>4.Mendekati lebih penting dari</option>
<option value='5'>5.Lebih penting dari</option>
<option value='6'>6.Mendekati sangat penting dari</option>
<option value='7'>7.Sangat penting dari</option>
<option value='8'>8.Mendekati mutlak dari</option>
<option value='9'>9.Mutlak sangat penting dari</option>
</select></td>
<td><input name='Matriks".($y).($z)."' type='radio' class='radiokanan' readonly='true' value='kiri'><input type='text' value='".$kriteria[$z-1]."'></td>
</tr>";
}
}
echo "</table>";
?>
<?php
}
$nama = $_POST['nama'];
$alamat = $_POST['alamat'];
echo"<input type='hidden' name='nama' value='$nama'>";
echo"<input type='hidden' name='alamat' value='$alamat'>";
?>
<hr color="#cccccc" />
<input type="submit" id="lanjut" name="lanjut" value="Lanjut" />
</form>
</div>
</div>
</div>
</div>
<div class="clearfix"> </div>
<div id="footer-bar" class="down-bar">
<div class="col">
<div class="text"><? echo date("l ,j F Y") ?></div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<div id="footer" class="container">
<p>....-------...</p>
</div>
</body>
</html>
$valid = true;
for ($y=1; $y<=$jmlKrit; $y++){
for ($z=$y+1; $z<=$jmlKrit; $z++){
$name = 'Matriks'.$y.$z;
if(!isset($_POST[$name])){
$valid = false;
echo 'Silahkan pilih kiri atau kanan';
}
}
}
<?php
$valid = true;
for ($y=1; $y<=$jmlKrit; $y++){
for ($z=$y+1; $z<=$jmlKrit; $z++){
$name = 'Matriks'.$y.$z;
if(!isset($_POST[$name])){
$valid = false;
echo'silakan pilih kiri atau kanan';
}
$kriteria[$z-1] = $kriteria[$z-1];
echo
"<tr>
<td><input type='text' value='".$kriteria[$y-1]."'><input name='Matriks".($y).($z)."' type='radio' class='radiokiri' readonly='true' value='kanan'></td>
<td>
<select style='text-align:justify;' class='box' name='M".($y).($z)."'>
<option value='1'>1.Sama penting dengan</option>
<option value='2'>2.Mendekati sedikit lebih penting dari</option>
<option value='3'>3.Sedikit lebih penting dari</option>
<option value='4'>4.Mendekati lebih penting dari</option>
<option value='5'>5.Lebih penting dari</option>
<option value='6'>6.Mendekati sangat penting dari</option>
<option value='7'>7.Sangat penting dari</option>
<option value='8'>8.Mendekati mutlak dari</option>
<option value='9'>9.Mutlak sangat penting dari</option>
</select></td>
<td><input name='Matriks".($y).($z)."' type='radio' class='radiokanan' readonly='true' value='kiri'><input type='text' value='".$kriteria[$z-1]."'></td>
</tr>";
}
}
echo "</table>";
?>
if($_POST){ // setelah user menakan tombol submit
$valid = true;
for ($y=1; $y<=$jmlKrit; $y++){
for ($z=$y+1; $z<=$jmlKrit; $z++){
$name = 'Matriks'.$y.$z;
if(!isset($_POST[$name])){
$valid = false;
echo 'Silahkan pilih kiri atau kanan';
}
}
}
}