View: 2184|Reply: 3
|
alert untuk dinamik radio button x jadi
[Copy link]
|
|
xnampak gambaq apa2 pong |
|
|
|
|
|
|
|
aLieNzDaToR posted on 30-8-2012 09:51 AM
xnampak gambaq apa2 pong
tular pasal.. kang nak copy paste pening lak baca...
nie radio button coding
<script type="text/javascript">
var q=0;
</script>
<?php
$sqlSoalan = "select * from lookup_soalan where noItem=9";
$rsltSoalan = mysql_query($sqlSoalan);
while($rowSoalan = mysql_fetch_array($rsltSoalan)){
?>
</td>
<tr>
<td> </td>
<td height="24" colspan="2">
<?php echo $rowSoalan['keterangan'];?> </td>
<td> <input type="hidden" name="txtItem<?php echo $i; ?>" value="<?php echo $rowSoalan['item'];?>"></td>
<td height="5" width="35"> <div align="center">
<input type="radio" name="radio<? echo $i.$rowLaporan ['namapenceramah'];?>" id="radio<? echo $i;?>" value="1" />
</div></td>
<td height="5" width="31"> <div align="center">
<input type="radio" name="radio<? echo $i.$rowLaporan ['namapenceramah'];?>" id="radio<? echo $i;?>" value="2" />
</div></td></td>
<td height="5" width="32"> <div align="center">
<input type="radio" name="radio<? echo $i.$rowLaporan ['namapenceramah'];?>" id="radio<? echo $i;?>" value="3" />
</div></td>
<td height="5" width="34"> <div align="center">
<input type="radio" name="radio<? echo $i.$rowLaporan ['namapenceramah'];?>" id="radio<? echo $i;?>" value="4" />
</div></td>
yang nie buat utk alert..
function allAlert()
{
var erroradio=1;
for(y=1;y<<?php echo $i;?>;y++)
{
if (getCheckedValue('radio'+y)==0){
erroradio=0;
}
}
if(erroradio==0){
alert('Sila jawab soalan');
return false;
}
}
function getCheckedValue(Varobj,Varmsg){
var objRadio="document.radio_form."+Varobj;
var RobjRadio=eval(objRadio);
var tanda= 0;
for(i=0;i < RobjRadio.length; i++){
if(RobjRadio.checked==true){
// alert("TAk cek "+i+" "+Varmsg);
tanda= 1;
}
}
return tanda;
}
</script>
|
|
|
|
|
|
|
| |
|