情况是我已经写出像
这样的代码<input type="text" name="date"<?php if(empty($date)){echo 'id="date"';}else{echo 'value='.$date;} ?> readonly/>
整页编码
<?php
session_start();
if(isset($_SESSION['rec_id']))
{
$enginenumber = $_SESSION['engn'];
$model = $_SESSION['mod'];
$vinnumber = $_SESSION['vinn'];
$date = $_SESSION['date'];
$time = substr($_SESSION['time'],0,5);
$bikeid = $_SESSION['bk_id'];
$recid = $_SESSION['rec_id'];
}
else
{
$enginenumber = "";
$model = "";
$vinnumber = "";
$date = "";
$time = "";
}
$_SESSION['line'] = $_GET['line'];
$linenumber = $_SESSION['line'];
$_SESSION['station'] = $_GET['st'];
include('../../php/dbconnectmssql.php');
?>
<html lang="en">
<head>
<title>TH Bike Assembly RFT Database</title>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="../../css/main.css"/>
<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
<link rel="stylesheet" type="text/css" href="../../css/external.css"/>
<link rel="stylesheet" type="text/css" href="../../css/formrecords.css"/>
<link rel="stylesheet" type="text/css" href="../../css/inputtabconroll2c.css"/>
<script type="text/javascript" src="../../js/date_time.js"></script>
<script type="text/javascript" src="../../js/jsdialog.js"></script>
<script type="text/javascript" src="../../js/validate.js">window.onload=function(){validateform();}</script>
<script type="text/javascript">window.onload=function(){GetClock();setInterval(GetClock,1000);}</script>
</head>
<body>
<div class="main rft">
<h1>Right First Time Record Line <?php echo $linenumber; ?> Chassis</h1>
<form name="stationrec" method="post" action="../php/stationrec.php">
<table class="headform">
<tr>
<td>
<p>VinNumber</p>
<input type="text" name="vinnumber" value="<?php echo $vinnumber; ?>"
<?php if(!empty($vinnumber)){echo "readonly";} ?>/>
</td>
<td>
<p>Engine Number</p>
<input type="text" name="enginenumber" value="<?php echo $enginenumber; ?>"
<?php if(!empty($enginenumber)){echo "readonly";} ?>/>
</td>
<td>
<p>Model</p>
<input type="text" name="model" value="<?php echo $model; ?>"
<?php if(!empty($model)){echo "readonly";} ?>/>
</td>
</tr>
<tr>
<td>
<p>Date</p>
<input type="text" name="date"
<?php if(empty($date)){echo 'id="date"';}else{echo 'value="'.$date.'"';} ?> readonly/>
</td>
<td>
<p>Time</p>
<input type="text" name="time"
<?php if(empty($date)){echo 'id="time"';}else{echo 'value="'.$time.'"';} ?> readonly/>
</td>
<td>
<input id="" class="myButton" type="submit" value="Bike-Pass/NewBike"/>
</td>
</tr>
</table>
</form>
<div id="faultpanel" class="container">
<div class="">
<h2>Fault Records</h2>
<div class="tabbedcontain">
<ul class="col4">
<li id="fhlschs" onclick="scchs()">Chassis</li>
<li id="fhlsuk" onclick="scuk()">UK</li>
</ul>
</div>
<div class="ftlscon">
<div id="ftlschs" class="col8">
<table>
<tr>
<th>Main Problem</th>
<th>Location</th>
<th>FoundBy</th>
<th>Chassis Number</th>
<th>Station</th>
<th>Damage Grade</th>
<th>More Info</th>
<th>Inv Chs Need</th>
</tr>
<?php
if(isset($_SESSION['rec_id']))
{
$sql = "select mainproblem,location,chassisNo,foundby,station,damage_grade,moreinfo,invchss
from dbo.fault_st2_rec
where st2_rec_id like ".$recid."and c_id like 5";
$query = sqlsrv_query($conn , $sql);
if($query === false)
{
die(print_r(sqlsrv_errors(),true));
}
while ($count = sqlsrv_fetch_array($query,SQLSRV_FETCH_ASSOC))
{
echo "<tr>";
foreach($count as $x => $a)
{
echo "<td>".$a."</td>";
}
echo "</tr>";
}
}
?>
</table>
</div>
<div id="ftlsuk" class="col5">
<table>
<tr>
<th>Main Problem</th>
<th>Location</th>
<th>Cause By</th>
<th>Found By</th>
<th>More Info</th>
</tr>
<?php
if(isset($_SESSION['rec_id']))
{
$sql = "select mainproblem,location,causeby,foundby,moreinfo
from dbo.fault_st2_rec
where st2_rec_id like ".$recid."and c_id like 6";
$query = sqlsrv_query($conn , $sql);
if($query === false)
{
die(print_r(sqlsrv_errors(),true));
}
while ($count = sqlsrv_fetch_array($query,SQLSRV_FETCH_ASSOC))
{
echo "<tr>";
foreach($count as $x => $a)
{
echo "<td>".$a."</td>";
}
echo "</tr>";
}
}
?>
</table>
</div>
</div>
</div>
<input id="add" class="myButton" type="button" value="Add Problem" onclick="formshow()">
<input id="" class="myButton" type="button" value="Back" onclick="recmanu()"/>
<div id="addform" class="popupformcontainer">
<div class="popupform">
<div class="tabbedcontain">
<ul class="col2">
<li id="chs" onclick="scchs()">Chassis</li>
<li id="uk" onclick="scuk()">UK</li>
</ul>
</div>
<div class="formcontain">
<div id="chsprob">
<form name="chassis" action="php/svfultrec.php" onsubmit="return validateForm('chassis',['mainprob','location','foundby','chsno','station','damg'])" method="post">
<h2>Fault by Chassis</h2>
<table class="fromtable">
<tr>
<td>Main Problem</td>
<td><input name="mainprob" type="text" placeholder="Mainproblem"/></td>
</tr>
<tr>
<td>Location</td>
<td><input name="location" type="text" placeholder="Location"/></td>
</tr>
<tr>
<td>Found By</td>
<td><input name="foundby" type="text" placeholder="Found By"/></td>
</tr>
<tr>
<td>Chassis No</td>
<td><input name="chsno" type="text" placeholder="Chassis No"/></td>
</tr>
<tr>
<td>Station</td>
<td><input name="station" type="text" placeholder="Station"/></td>
</tr>
<tr>
<td>Damage Grade</td>
<td><input name="damg" type="text" placeholder="Damage Grade"/></td>
</tr>
<tr>
<td>More Info</td>
<td><input name="mrinfo" type="text" placeholder="More Info"</td>
</tr>
<tr>
<td>Inv Chs Need ?</td>
<td><input id="checkbox" name="invst" type="checkbox" value="true"/></td>
</tr>
<td colspan="2">
<input class="myButton" type="submit" value="Add" name="chassis"/>
<input class="myButton" type="reset" value="Reset"/>
<input class="myButton" type="button" value="Cancle" onclick="formhide()"/>
</td>
</table>
</form>
</div>
<div id="ukprob">
<form name="uk" action="php/svfultrec.php" onsubmit="return validateForm('uk',['mainprob','location','foundby'])" method="post">
<h2>Fault by UK</h2>
<table>
<tr>
<td>Main Problem</td>
<td><input name="mainprob" type="text" placeholder="Mainproblem"/></td>
</tr>
<tr>
<td>Location</td>
<td><input name="location" type="text" placeholder="Location"/></td>
</tr>
<tr>
<td>Cause By</td>
<td><input name="causeby" text="text" placeholder="Cause By"/></td>
</tr>
<tr>
<td>Found By</td>
<td><input name="foundby" type="text" placeholder="Found By"/></td>
</tr>
<tr>
<td>More Info</td>
<td><input name="mrinfo" type="text" placeholder="More Info"/></td>
</tr>
<tr>
<td colspan="2">
<input class="myButton" type="submit" value="Add" name="uk"/>
<input class="myButton" type="reset" value="Reset"/>
<input class="myButton" type="button" value="Cancle" onclick="formhide()"/>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
关于输入表格。 我能提供的任何信息请问我
问题是......当变量不为空时,
(这意味着php回显'value ='.$date
)
值不会被我回复的php取代。
我需要刷新页面才能正确显示值。
我还在谷歌浏览器的开发者工具中查看源代码,事情是.....它被替换但每次都需要刷新才能正常显示。
我想要做的是,如何在没有刷新页面或其他类型的东西的情况下正确显示回显的值?
//纯粹的js / php会很好
更新 在IE渲染输出中正常工作
updated2 我已经写出了使其再次刷新页面的代码暂时,我仍然想知道是否可以在没有刷新页面的情况下正确显示?
if(isset($_SESSION['refresh']))
{
if($_SESSION['refresh'] === true)
{
echo "<script> window.location.reload(); </script>";
$_SESSION['refresh'] = false;
}
}
抱歉我的英文不好
由于
答案 0 :(得分:0)
在此处添加双引号或单引号document.body.style.background = "Red";//Showing Red Color
从
改变window.onload = changecolors;
要
'value='.$date;}
答案 1 :(得分:0)
PHP可以正常工作,但由于生成的html
代码包含一些错误,html
无法正确呈现输出。如果$date
不为空(例如它包含17-08-2015),则从代码中输出如下输出:
<input type="text" name="date"value=17-08-2015 readonly/>
但它应该是这样的:
<input type="text" name="date" value="17-08-2015" readonly/>
因此,更改您的PHP代码以生成正确的输出。像:
<input type="text" name="date" <?php if(empty($date)){echo 'id="date"';}else{echo 'value="'.$date.'";} ?> readonly/>