如何在javascript中传递值并在另一个页面上获取它?
JavaScript如何在javascript中传递值并在另一个页面上获取它?,javascript,php,jquery,Javascript,Php,Jquery,JavaScript function resultfunction() { var result = document.getElementById("result"); window.location.href = "deleteresult.php?did="+result; } PHP <select id="result"> <?php include 'model.php'; $rs=new database(); $res=$r
function resultfunction() {
var result = document.getElementById("result");
window.location.href = "deleteresult.php?did="+result;
}
PHP
<select id="result">
<?php
include 'model.php';
$rs=new database();
$res=$rs->result();
while($row=mysql_fetch_array($res)){
$did=$row["id"];
$dterm=$row["term"];
?>
<option id="<?php echo $dterm;?>"><?php echo $dterm;?></option>
<?php } ?>
</select>
<a href="#" onclick="resultfunction()" class="btn dropdown-toggle">Delete </a>
使用以下命令:
选择1
选择2
选择3
函数resultfunction(){
var select=document.getElementById(“结果”);//首先,您需要在选项上设置一个值,例如:
<option id="option1" value='1'>option 1</option>
选择1
选择2
选择3
要在deleteresult.php页面上使用该变量,u应该有如下代码
$get_did = $_GET['did'];
$\会话['did']=$did;您可以在所有页面上使用它。有关更多信息,请获取php会话文档。还有一件事我想问,当我从数据库中获取术语时,有很多重复值,但我只需要一次,无论它在数据库中重复多少次。还有一件事我想问,当我从数据库中获取术语时,有很多重复值f重复值,但我只想要一次,无论它在数据库中重复多长时间。还有一件事我想问,当我从数据库中提取术语时,有很多重复值,但我只想要一次,无论它在数据库中重复多长时间databse@YogeshArya,我不知道你为什么要做这样的事nds是关于数据库表的结构的,但我认为您可以更改SELECT
查询,例如:selectdistinct field\u name FROM table\u name;
,这样您应该返回唯一的值。