我正在研究一个我从另一个人手中接过的PHP程序。这是程序中使该字段可编辑的代码的一部分:
<td class='none'>
<?php
if($repair[0]['description'] == "")
{
echo "<input class='width' id='description' value=\"" . $repair[0]['description'] . "\">";
}
else
{
?>
<div id='descriptionDiv'>
<a href="javascript:changeDiv('descriptionDiv', 'descriptionDiv2')" title='klik om te wijzigen' class='edit'><?php echo $repair[0]['description']; ?></a>
</div>
<div id='descriptionDiv2' style='display=none'>
<input class='width' id='description' value="<?php echo $repair[0]['description']; ?>">
</div>
<?php
}
?>
</td>
为了更好地理解这一点,请查看图片:
蓝色字段可编辑。
有一个带* .tpl扩展名的文件,我有一个view.php文件,其中包含以下代码:
<?php
public function renderShowInspectionDocument()
{
setLastPage();
$dochtml = '';
//Verwijder alles totdat je een '/' tegenkomt (begin rechts). Hiermee verwijder je eventueel de 'index.php' in de url.
$url = str_replace(end(explode('/', $_SERVER['SOMETHING'])), '', $_SERVER['SOMETHING']);
//Template
$template = file_get_contents('templates/inspectionDetails.tpl');
if(isset($this->data['SJB']))
{
$SJB = $this->data['SJB'];
$dochtml .= '<tr>';
$dochtml .= '<td class="label">Inspecton:</td>';
$dochtml .= '<td><div style="width:420px; font-weight:normal; border-left:1px solid black; border-bottom:1px solid black; padding:5px;">'. nl2br($SJB['inspection_requirement']) .'</div></td>';
$dochtml .= '</tr>';
$dochtml .= '<tr>';
$dochtml .= '<td class="label">Inspection-Tools:</td>';
$dochtml .= '<td><div style="width:420px; font-weight:normal; border-left:1px solid black; border-bottom:1px solid black; padding:5px;">'. nl2br($SJB['inspection_resources']) .'</div></td>';
$dochtml .= '</tr>';
if(isset($SJB['extra_document']) && !empty($SJB['extra_document']))
{
$dochtml .= '<tr>';
$dochtml .= '<td class="label">Extra document:</td>';
$dochtml .= '<td><a target="_blank" href="'. $url .'uploads/SJB/'. urlencode($SJB['extra_document']) .'">'. $SJB['extra_document'] .'</a></td>';
$dochtml .= '</tr>';
}
$dochtml .= '<tr><td> </td></tr>';
}
?>
和.tpl有:
<div class="navigation" id="navigationDiv">
</div>
<style type="text/css">
table td {
border: none;
}
</style>
<table class="clean">
{data}
<tr style="display:{display};">
<td class="label">Special:</td>
<td>{notices}</td>
</tr>
</table>
{back}
我希望能够使这些字段也可以编辑,但我需要帮助,也许有人可以提供帮助?
由于某些原因,图像无法加载!!