ถามผู้รู้ - มีปัญหาการดึง value ใน php ไปยัง js
คือว่าถ้าอยู่นอก loop while ไม่มีปัญหา ดึงได้ (ได้ทดสอบค่าคงที่ ) แต่พอเอาเข้าไป
ใน loop แล้ว ดึงไม่ออก undefine ทั้งค่าคงที่ และ id ที่ต้องการจะดึงออกมา
รบกวนผู้รู้ช่วยแนะนำด้วยครับ
มือใหม่ js
<?session_start() ; ?>
<? ob_start();?>
<body TEXT-ALIGN= "left" VALIGN = "left" TOPMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="30" bgcolor="azure">
<?
$count = "0" ;
if (isset($HTTP_POST_VARS)) {
// if ($Sub_Module ==" Submit "){
IF ($HTTP_POST_VARS["Check_id"] != "") {
$fruit = $HTTP_POST_VARS["Check_id"];
?>
<form method="post" Name = "yyy" >
<table align = "left" width = "290" border = "0" cellspacing = "0" cellpadding = "0" >
<?
for ($i=0; $i<count($fruit); $i++)
{
$Topicgr_id = $fruit[$i];
$sql = "SELECT * FROM Topic WHERE GroupTopicID = '$Topicgr_id' ORDER BY TopicID DESC " ;
$resultn = mysql_query($sql) ;
$numrow = mysql_num_rows($resultn);
?>
<tr><td>
<table align = "left" width = "560" border = "0" cellspacing = "0" cellpadding = "0" >
<?
while ( $row = mysql_fetch_array($resultn,MYSQL_ASSOC) ) {
if($count == 0) {
?>
<tr>
<td align = left height = '6' width= '4%'><font color="#990000" size="1" face=" tahoma, ms sans serif, sans-serif"><input type = "checkbox" name = Check_id[] value=<?= $row["TopicID"];?> >
</td>
<td align = left height = '6' width= '80%'><font size="2" color="#990000" face=" tahoma, ms sans serif, sans-serif"><a href="../function/Add_eModule.php?BL_name=5&Adtp=<?=$row["TopicID"]?>"> <?echo $row["TpSubject1"] ?> </a></td>
<td align = left height = '6' ><font size="2" color="#990000" face=" tahoma, ms sans serif, sans-serif"><a href = # onClick = "Show_onfr2()" > <? echo "Selvvvvvect..." ; ?> </a></font></td>
</tr>
<?
$count = 1 ;
}
else
{
?>
<tr>
<td align = left height = '6' width= '6%'><font color="#990000" size="1" face=" tahoma, ms sans serif, sans-serif"><input type ="checkbox" name = Check_id[] value=<?= $row["TopicID"];?> ></td>
<td align = left height = '6' width= '80%'><font size="2" color="#990000" face=" tahoma, ms sans serif, sans-serif"><a href="../function/Add_eModule.php?BL_name=5&Adtp=<?=$row["TopicID"]?>"><?echo $row["TpSubject1"] ?> </a></td>
<td align = left height = '6' ><font size="2" color="#990000" face=" tahoma, ms sans serif, sans-serif"><a href="../function/Edit_eModule.php?BL_name=14&Edtp=<?=$row["TopicID"]?>"> <? echo "Select..." ; ?> </a></font></td>
<?
$count = 0 ;
}
}
?>
</table>
</td></tr>
<?
$Topicgr_id=0;
}
} else {
?>
<div style="position:absolute;top:120;left: 30;">
<table align = "center" width = "250" border = "0" cellspacing = "0" cellpadding = "0" bgcolor= "azure">
<tr>
<td align = left width = "100%"><font size="2" color="#990000" face=" tahoma, ms sans serif, sans-serif"> Please Select the Module that you interest...left menu! </font</td>
</tr>
</table></div>
<?
}
}
?>
<! tr><td>
<! div style="position:absolute;top:155;left:0;">
<! table align = "left" width = "155" border = "0" cellspacing = "0" cellpadding = "0" bgcolor= "azure">
<tr bgcolor= "white">
<! input type="hidden" name="Topicx" value="<?echo $row["TopicID"] ; ?>" >
<! input type="submit" name="Sub_Module" value = " Submit ">  <! input type="reset" name="del_edit_" value = " Clear ">
<! /tr>
<! /table></div>
<! td></tr>
</table>
</form>
</body>
<SCRIPT LANGUAGE ="JavaScript" >
function Show_onfr2()
{
// document.write("sdfafafafad") ;
var Ed = document.yyy.Check_id[] .value ; < ตัวนี้แหล่ะ ที่ต้องการจะดึง
document.write ( Ed ) ;
var ad = 5 ;
// document.write (ad) ;
window.location.href = "../function/Add_eModule.php?BL_name="+ad+"&rd="+Ed ;
}
</SCRIPT>
Tag : - - - -
Date :
19 พ.ค. 2548 07:12:18
By :
บอย
View :
2176
Reply :
1
Code (PHP)
$var = "value";
<script language="JavaScript">
alert('<?=$var;?>');
</script>
Date :
2011-07-23 20:04:55
By :
thaicreate
Load balance : Server 00