我希望这不是重复,但我还没有找到它。
说实话,我在网上发现了这种方法,并且无法找到我原来找到的地方,或者我会在那里搜索答案。以下是我正在测试我的代码的测试页面。
我的问题是如何将时钟值保存在href中并将cellnumber添加到href?现在我得到dropdowntest.php?cellnumber = 8&?clock = 8这个值与我认为在行中的单元号相同:
+ ['?cellnumber', $(this).val()].join('=') + ['&?clock', $(this).val()].join('=');
我已尝试在时钟上更改$(this)但我找不到正确的语法..下面是所有代码:
<?php
session_start();
require('/db_connection/connect.db.php');
require('settings.php');
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.clock').on('change', function() {
location.href = location.href.split('?')[0]
+ ['?clock', $(this).val()].join('=');
});
$('.cellnumber').on('change', function() {
location.href = location.href.split('?')[0]
+ ['?cellnumber', $(this).val()].join('=') + ['&?clock', $(this).val()].join('=');
});
});
</script>
<?php
$clock = mysqli_query($connection, "SELECT username FROM user WHERE wocreate = 1 and hide = 1");
echo "<select class='clock' name='clock' style='width:200px'>";
echo "<option size =30 ></option>";
while($row = mysqli_fetch_array($clock)){
echo "<option value='".$row['username']."''>".$row['username']."</option>";
}
echo "</select>";
if (isset($_GET['clock'])) {
$_SESSION['clock'] = $_GET['clock'];
echo "<p></p>";
echo 'Person Requesting Ticket is '.$_SESSION['clock'].'';
echo "<p></p>";
}
?>
<?php
echo "<br>";
$cellnumbers = mysqli_query($connection, "SELECT DISTINCT location FROM machinenumber WHERE status = 1 ");
echo "<select class='cellnumber' name='cellnumber' style='width:200px'>";
echo "<option size =30 ></option>";
while($row = mysqli_fetch_array($cellnumbers)){
echo "<option value='".$row['location']."''>".$row['location']."</option>";
}
echo "</select>";
if (isset($_GET['cellnumber'])) {
$_SESSION['cellnumber'] = $_GET['cellnumber'];
echo "<p></p>";
echo 'Person Requesting Ticket is '.$_SESSION['clock'].'';
echo "<br>";
echo 'Cell '.$_SESSION['cellnumber'].' is the location';
echo "<p></p>";
}
?>
<?php
if (isset($_GET['cellnumber'])) {
$cellnumber=$_GET['cellnumber'];
echo "<h3>Choose Machine Number</h3>";
$machinenumber = mysqli_query($connection,"SELECT number FROM machinenumber WHERE location =".$cellnumber." ;");
echo "<select class='machinenumber' name='machinenumber' style=width:200px>";
echo "<option size =30 ></option>";
while($row = mysqli_fetch_array($machinenumber)) {
echo "<option value='".$row['number']."'>".$row['number']."</option>";
}
echo "</select>";
}
?>