我有以下php页面, 它有一个下拉框,当选择值关闭时,它意味着打开一个文本框。 我已经嵌入了PHP内的JavaScript,但由于某种原因它不起作用。
<?php
require_once "/var/www/users/user.php";
$user = new CHUser(2);
require_once "/var/www/template/template.php";
$template = new CHTemplate();
require_once "/var/www/ENGINEER/DisplayWIPOnLocation.php";
$BundleProgress= new CHWIPProgress();
$todays_date = date('Y-m-d H:i:s');
$ID = $_GET['id'];
//$ID = $_POST['ID'];
$ChurchNo = $_POST['ChurchNo'];
$SerialNo = $_POST['SerialNo'];
$MachineType= $_POST['MachineType'];
$Model = $_POST['Model'];
$Location= $_POST['Location'];
$Priority = $_POST['Priority'];
$Issue = $_POST['Issue'];
$Status = $_POST['Status'];
$Call_Opened = $_POST['Call_Opened'];
//echo "test component $Component";
$wip = $BundleProgress-> ListTicketById($_GET['id']);
foreach($wip as $x) {
$ChurchNo = $x['ChurchNo'];
$SerialNo = $x['SerialNo'];
$MachineType= $x['MachineType'];
$Model = $x['Model'];
$Location= $x['Location'];
$Priority = $x['Priority'];
$Issue = $x['Issue'];
$Status = $x['Status'];
$Call_Opened = $x['Call_Opened'];
$Operator = $x['Operator'];
$Engineer = $x['Engineer'];
$Notes = $x['Notes'];
}
$content .="
<html>
<head>
<title></title>
<script language='JavaScript' type='text/javascript'>
function ShowTB(obj,id){
txt=obj.options[obj.selectedIndex].text;
if (txt.match('Pending')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Closed')){
document.getElementById(id).style.visibility='visible';
}
}
</script>
</head>
<body>";
$content .="
<p><b>You are changing the status of call no: $ID </b></p>
<table>
<tr><td> <b>ChurchNo</b>:$ChurchNo </td> </tr>
<tr><td> <b>SerialNo</b>: $SerialNo</td> </tr>
<tr><td> <b>MachineType</b>: $MachineType</td> </tr>
<tr><td> <b>Model</b>: $Model </td> </tr>
<tr><td> <b>Location</b>:$Location </td> </tr>
<tr><td> <b>Priority</b>: $Priority </td> </tr>
<tr><td> <b>Issue</b>: $Issue </td> </tr>
<tr><td> <b>Status</b>: $Status </td> </tr>
<tr><td> <b>Date Opened</b>:$Call_Opened </td> </tr>
<tr><td> <b>Operator</b>:$Operator </td> </tr>
<tr><td> <b>Logged By</b>:$Engineer </td> </tr>
</table>
</br>
</br>
<table>
<form method='post' action='UpdateTicket2.php'>
<tr><td><b>Assign to: </b></td> <td> <select name='Assignedto'>
<option value='David'>David</option>
<option value='Ashley'>Ashley</option>
<option value='Pete'>Pete</option>
<option value='Mark'>Mark</option>
<option value='Rory'>Rory</option>
</select>
</td>
</tr>
";
$content .="
<tr><td><b>Status </b></td>
<td>
<select onchange=\"ShowTB(this,'Date');\" >
<option >Open</option>
<option >Closed</option>
<option >Pending</option>
</select>
<br>
<input id='Date' style='visibility:hidden;' >
</td>
<tr> ";
$content .="
<tr><td><b>Notes:</b></td><td><textarea name='Notes' cols='25' rows='5'>
$Notes
</textarea></td></tr>
<tr><td><b>Current Time: $todays_date</b></td></tr>
<tr><td><input type='hidden' name='ID' id='ID' value='$ID' /></td></tr>
<tr><td><input type='submit' name ='add'/></td></tr>
</form>
</table>
";
$content .="
</br>
<p> Warning.... </p>
<form action='delete.php' method='post'>
<input type='submit' value='Delete Record' />
<p><input type='hidden' name='ID' id='ID' value='$ID' /></p>
</form>";
$template->SetTag("content", $content);
echo $template->Display();
?>
答案 0 :(得分:0)
用于测试目的: 在您的计划开始之前发表评论
/*
*/
$content .="
然后改变:
$template->SetTag("content", $content);
echo $template->Display();
有:
echo $content;
最后,内部脚本标记写:
alert('Javascript is working');
我做到了并让程序运行。您的问题出在$ template类中,而不是在此代码中。
干杯,