-1
只是形式上的所有其他領域的第一場顯示值顯示空白,即使這些字段具有值僅顯示在HTML表單首先取指令字段
我已經賺得一些領域從MySQL查詢,但它顯示只有第一個獲取的字段,如果我複製第一個獲取的字段的名稱作爲所有輸入框的形式的值,它只顯示第一個其他是空白的。 其他列顯示我回顯這些列時的值。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Library Information</title>
</head>
<body>
<?php
//include 'Header.php';
include 'AHome.php';
require_once("connect.inc.php");
$conn = mysqli_connect(HOST, DBUSER, PASS,DB) or die('Could not connect !<br />Please contact the site\'s administrator.');
$result = mysqli_query($conn,"SELECT NM , ADDRESS1 , ADDRESS2 , CITY , STATE , COUNTRY , PHONENO , FAXNO , EMAIL1 FROM library_info LIMIT 1 ");
if($result)
{
while($row = mysqli_fetch_array($result))
{
$Nm1 = $row['NM'];
$Add1 = $row['ADDRESS1'];
$Add2 = $row['ADDRESS2'];
$City = $row['CITY'];
$State = $row['STATE'];
$Country = $row['COUNTRY'];
$Phone = $row['PHONENO'];
$Fax = $row['FAXNO'];
$Email1 = $row['EMAIL1'];
echo $Add1;
echo "<form name='Lib-Info' id='Lib-Info' method='post' onsubmit='return validate()' action='LibInfo.php' >
<fieldset>
<legend>
Basic Information
</legend>
<dl>
<dt>
Name: <input tabindex='1' accesskey='n' name='Nm' type='text' maxlength='200' id='Nm' value = \"$Nm1\" />
</dt>
</dl>";
echo "<dl><dt>
Address Line 1 <input tabindex='2' accesskey='A' Name='Add1' type='text' maxlength='200' id='Add1' \"$Nm1\" />
</dt></dl>";
echo "<dl><dt>
Address Line 2 <input tabindex='3' accesskey='B' Name='Add2' type='text' maxlength='200' id='Add2' \"$Nm1\" />
</dt></dl>
<dl><dt>
City: <input tabindex='4' accesskey='C' Name='City' type='text' maxlength='50' id='City' \"$Nm1\" />
</dt></dl>
<dl><dt>
State <input tabindex='4' accesskey='S' Name='State' type='text' maxlength='200' id='State' \"$Nm1\" />
</dt></dl>
<dl><dt>
Country: <input tabindex='5' accesskey='B' Name='Country' type='text' maxlength='200' id='Country' \"$Nm1\" />
</dt></dl>
</fieldset>
<fieldset>
<legend>Contact Details</legend>
<dl><dt>
Contact No: <input tabindex='6' accesskey='P' Name='Phone' type='text' maxlength='200' id='Phone' \"$Nm1\" />
</dt></dl>
<dl><dt>
Fax No.: <input tabindex='7' accesskey='F' Name='Fax' type='text' maxlength='200' id='Fax' \"$Nm1\" />
</dt></dl>
<dl><dt>
E-Mail: <input tabindex='8' accesskey='E' Name='Email' type='text' maxlength='200' id='Email' \"$Nm1\" />
</dt></dl>
</fieldset>
<label title='Submit'>
<input tabindex='9' accesskey='l' type='submit' name='Submit' value='Submit' />
</label>
</form>";
}
}
else
{
die(mysqli_error($con));
}
include 'footer.php';?>
</body>
<script>
function validate()
{
var Nm = document.getElementById("Nm")
if(Nm.value=='')
{
alert("Library Name required");
return(false);
}
Nm = '';
Nm = document.getElementById("Add1");
if(Nm.value=='')
{
alert("Address Line 1 required");
return(false);
}
Nm = '';
Nm = document.getElementById("Phone");
if(Nm.value=='')
{
alert("Contact No. required");
return(false);
}
Nm = '';
Nm = document.getElementById("Email");
if(Nm.value=='')
{
alert("Mail address required");
return(false);
}
Nm = document.getElementById("");
if(Nm.value=='')
{
alert("Library Name Required");
return(false);
}
}
</script>
</html>
結果
您面臨的問題是什麼。 –
您錯過了每個輸入標籤上的屬性'value'和變量的名稱應該是相關的。 – C2486