|
|
|
มันใช้ได้ loop แรกลูปเดียวต้องแก้ยังไง ครับ พอดีเพิ่งหัดใช้ js |
|
|
|
|
|
|
|
Code (PHP)
<link rel="stylesheet" type="text/css" href="menu.css" />
<script language="JavaScript">
var i=o;
</script>
<?php
$sql=mysql_query("SELECT * FROM law ORDER BY QuestionID DESC LIMIT 20");
mysql_query("SET NAMES UTF8");
while($row=mysql_fetch_array($sql))
{
$msgID= $row['QuestionID'];
$msg= $row['Question'];
$Details = $row['Details'];
$i=0;
?>
<script language="JavaScript">
i++;
function fncShow()
{
document.getElementById('data').innerHTML = '<?=$Details; ?>';
document.getElementById('readmore').innerHTML = '<input type="button" id="buttom" value="Hide" onClick="JavaScript:fncHide();"/>';
}
function fncHide()
{
document.getElementById('data').innerHTML = '<?
$text = $Details;
print iconv_substr($text,0,300,"UTF-8");
echo "......";
?>';
document.getElementById('readmore').innerHTML = '<input type="button" id="buttom" value="Readmore" onClick="JavaScript:fncShow();"/>';
}
</script>
<table width="95%" border="0">
<tr>
<td width="11%" valign="top"><img src="images/law.gif" width="150" height="135"></td>
<td width="89%" valign="top"><table width="100%" border="0">
<tr>
<td style="font-size:24px; font-weight:bold;" align="left"><?php echo " ",$msg; ?></td>
</tr>
<tr>
<td id="data" style="white-space:normal; color:#333;">
<?PHP
print iconv_substr($Details,0,300,"utf-8");
echo "...";
?>
</td>
</tr>
<tr>
<td id="readmore" align="right"><input type="button" id="buttom" value="Readmore" onClick="JavaScript:fncShow();"/>
</td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td width="3%"> </td>
<td width="94%"><hr></td>
<td width="3%"> </td>
</tr>
</table>
<div id="<?php echo $msgID; ?>" align="left" class="message_box" style="display:none">
<span class="number"><?php echo $msgID; ?></span><?php echo " ",$msg; ?>
</div>
<?php
}
?>
Tag : PHP, JavaScript, CakePHP
|
|
|
|
|
|
Date :
2012-09-28 21:44:59 |
By :
tazao |
View :
1016 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fncShow() และ function fncHide()
มันอยู่ใน loop
เอาไปสร้างนอก loop ครับ
|
|
|
|
|
Date :
2012-09-29 10:26:24 |
By :
ไวยวิทย์ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|