可能是一个非常简单的答案,但我对此只是新手。
我有一个表格,我正在根据我公司的现有表格进行修改。此表单有一个 jquery,它会在表单提交时获取下一个可用的索赔编号并将其提交到我的 mysql 数据库。
我正在尝试更改此表格以用于采购订单。每当商店选择的更改(下拉框中有 22 个站点的列表,它使用 onchange='getClaimNumber()' )时,jquery 函数都会被调用,所以我假设该数字在开始时就被选中了。
选择商店后,如何让表格显示此号码?理想情况下,表格应该能够打印出来并显示数字然后提交。我很高兴有一个按钮可以调用查询并在需要时显示它。
提前致谢。下面是我(非常糟糕)编写的代码。其中大部分是从我们以前的表格修改而来的......(出于隐私考虑,删除了一些信息)
<html>
<head>
<title>Purcahse Order</title>
<style>
body { font-family:sans-serif; font-size:13px; background-color:#F2F2F2; min-width:800px; }
table { font-family:sans-serif; font-size:13px; padding-bottom:30px;}
h1 { margin-top:15px; padding-top:0px; }
h2 { margin-bottom:0px; padding-bottom:10px; }
hr { border:none; border-bottom:1px solid #AAAAAA; }
input, textarea,select { font-family:sans-serif; font-size:13px; color:#333333; }
.Section1 { position:relative; width:950px; margin:0px auto; }
.left-col { width:130px; font-weight:bold; vertical-align:top;}
.left-col-w { width:230px; font-weight:bold; vertical-align:top;}
.pageno { width:100px; vertical-align:top; text-align:center;}
.lineno { width:100px; vertical-align:top; text-align:center;}
.productcodeno { width:110px; vertical-align:top; text-align:center;}
.descriptionofgoods { width:250px; vertical-align:top;}
.claimamount { width:150px; vertical-align:top; text-align:right;}
.qty { width:50px; vertical-align:top; text-align:center;}
.float-left { float:left; position:relative; margin-right:50px; }
.clear { clear:both; }
.x-small { font-size:11px; color:#777777; }
.footer { text-align:center; font-size:11px; color:#777777; }
</style>
<link type="text/css" href="css/smoothness/jquery-ui-1.8.16.custom.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/getClaimNumber.js"></script>
<!-- Disable the Enter key from submitting the form -->
<script type="text/javascript">
jQuery(document).ready(function($) {
textboxes = $("input:text");
if ($.browser.mozilla) {
$(textboxes).keypress(checkForEnter);
} else {
$(textboxes).keydown(checkForEnter);
}
function checkForEnter(event) {
if (event.keyCode == 13) {
currentTextboxNumber = textboxes.index(this);
if (textboxes[currentTextboxNumber + 1] != null) {
nextTextbox = textboxes[currentTextboxNumber + 1];
nextTextbox.select();
}
event.preventDefault();
return false;
}
}
});
</script>
<!-- Display the calendar on the datepicker id'd fields -->
<script type="text/javascript">
$(function() {
$( "#datepicker" ).datepicker({
dateFormat : 'yy-mm-dd',
});
});
</script>
<!-- Validate Form -->
<script type="text/javascript" src="js/validate.js"></script>
<script>
$(document).ready(function(){
$("#claim_form").validate();
});
</script>
<script>function getClaimNumber() {
var getclaimNumber = //whatever they are using currently to get the Claim Number
// They're probably not putting it into a variable now, just assigning
// it somewhere, but since you're going to need it twice
// put it into a variable for resuse.
// Do whatever you need to here to put it where it was going before.
$('#GetClaimNumber').text(GetclaimNumber);
} </script>
</head>
<body>
<div class=Section1>
<h1><center>***********</center></h1>
<h2>Purchase/Work Order<h2></center>
<hr size=2 width="100%" align=center />
<form action="./sent.php" method="post" name="claim_form" id="claim_form">
<center><table cellspacing="0" cellpadding="5" border="0" width="800px">
<tbody>
<tr>
<td class="left-col">Date:</td>
<td><? echo date('Y-m-d') ?></td>
<td></td>
<td></td>
</tr>
<tr>
<td class="left-col">Store Name:</td>
<td>
<?
$con = mysql_connect('localhost', 'root', '936200');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DB", $con);
$sql="SELECT * FROM StoreMaster ORDER BY HostID ";
$result = mysql_query($sql);
echo "<select name='store' class='required' onchange='getClaimNumber()'>";
echo "<option></option>";
echo "<option value='Service Centre'>Centre</option>";
echo "<option value='Fishers Accademy'>Accademy</option>";
while($row = mysql_fetch_array($result))
{
echo "<option value='$row[Name]'>" . $row['Name'] . "</option>";
}
echo "</select>";
mysql_close($con);
?>
<input type="hidden" name="sendto" id="sendto" value="" />
</td>
<td></td>
<td></td>
</tr>
<tr>
<td class="left-col">Department:</td>
<td>
<?
$con = mysql_connect('localhost', 'user', 'password');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$sql="SELECT * FROM DeptMaster WHERE Code IN (1,2,3,4,5,6,7,8,9,10) ORDER BY Code";
$result = mysql_query($sql);
echo "<select name='dept' class='required'>";
echo "<option></option>";
echo "<option value='Other'>Other</option>";
while($row = mysql_fetch_array($result))
{
echo "<option value='$row[Name]'>" . $row['Name'] . "</option>";
}
echo "</select>";
mysql_close($con);
?>
</td>
<td class="left-col">Staff Members Name:</td>
<td><input name="claimedby" class='required' id="claimedby" type="text"></input></td>
<td class="left-col">PO Number:</td>
<td></td>
</tr>
</tbody>
</table></center>
<div class="clear"></div>
<span id="displayClaimNumber"></span>
<h2><center>Supplier Information</h2>
<center><table cellspacing="0" cellpadding="5" border="0" width="800px">
<tbody>
<tr>
<td class="left-col">Supplier:</td>
<td><input name="suppliername" class='required' type="text"></td>
</tr>
<tr>
<td class="left-col">Phone:</td>
<td><input name="supplierphone"type="text"></td>
<td class="left-col">Fax:</td>
<td><input name="supplierfax"type="text"></td>
</tr>
<tr>
<td class="left-col">Address:</td>
<td colspan="3"><input type="text" name="supplieraddress" class="required" style="width:560px"></textarea></center></td>
</tr>
</tbody>
</table></center>
<script>$("ponumber").text</script>
<center><h3> Please supply the following and charge to the above account </h3></center>
<center><table cellspacing="0" cellpadding="5" border="2" width="800px">
<tbody>
<tr>
<th>Date</th>
<th>Desctiption/Items</th>
<th>Hours Worked</th>
<th>Amount</th>
</tr>
<?php
$i = 1;
while ($i <= 7) {
echo "<tr>";
echo " <input type='hidden' name='claimline" . $i . "' value='$i'></input>";
echo " <td align='center'><input class='lineno' name='lineno$i' type='text' maxlength='10'></td>";
echo " <td align='center'><input class='descriptionofgoods' name='descriptionofgoods$i' type='text'></td>";
echo " <td align='center'><input class='qty' name='qty$i' type='text' maxlength='5'></td>";
echo " <td align='center'>$ <input class='claimamount' name='claimamount$i' type='text'></td>";
echo "</tr>";
$i++;
}
?>
</tbody>
</table></center>
<div class="clear"></div>
<center><p>Authorised By:
<input name="desc8" type="text" id="desc8" size="50">
<input name="desc8" type="text" id="desc8" size="50">
(name)</p>
<p>Signed: ___________________________</p>
<p>(Hard copy must contain a signiture)</p>
<p><strong>PLEASE RETURN A COPY OF THIS DOCUMENT WITH YOUR INVOICE FOR PAYMENT</strong></p></center>
<input name="Submit" type="submit" value="Send »">
<INPUT TYPE="RESET" VALUE="Clear">
<input name="Print" type="submit" onclick="dlookup" value="Print">
</form>
<hr />
</div>
</body>
</html>