我有下面的脚本,让用户选择一个“文件夹”,然后 jquery 代码监听并显示代码。现在代码在一个选择框中,但我希望它们只显示为链接。这可能吗?
这是jQuery:
<script type="text/javascript">
$(document).ready(function () {
$("#theselect").change(function() {
var option = $(this).val();
var selectedUser = $("#thename").val();
$.get("selectfolders.php", {select:option,username:selectedUser},function(data){
$("#theresult").html(data).hide().fadeIn(1000);
});
});
});
</script>
这是查找和显示所有用户文件夹的 php 代码:(这是我想要的链接而不是选择框。)
<select name="theselect" id="theselect">
<option value="">Select</option>
<?
$thelistquery = mysql_query("SELECT * FROM folders WHERE username='$username'");
while ($lrows = mysql_fetch_array($thelistquery)) {
$id = $lrows['ID'];
$foldername = $lrows['foldername'];
$newfoldername = mysql_real_escape_string($foldername);
echo "<option value='$newfoldername'>$newfoldername</option>";
}
?>
</select>
选择文件夹.php
$username = $_GET['username'];
$theselect = $_GET['select'];
$thelistquery = mysql_query("SELECT * FROM folders WHERE username='$username'");
while ($lrows = mysql_fetch_array($thelistquery)) {
$id = $lrows['ID'];
$foldername = $lrows['foldername'];
$newfoldername = mysql_real_escape_string($foldername);
if($_GET['select'] == "$newfoldername") {
//What to display
}
}
?>