php頁傳值
不使用表單傳遞下拉框的值,其實很簡單用js獲取就能夠實現了,下面看代碼
<script type="text/javascript"> function getsel(){ var obj = document.getElementById("sel").value; if(obj== ""){ obj = "0"; } var newhref = "b.php?obj="+obj; var ona = document.getElementById('ona'); ona.href = newhref; } </script> <select id="sel"> <?php foreach ($sql_res as $value) { ?> <option value="<?php echo $value[belongs];?>"><?php echo $value[belongs];?></option> <?php };?> </select> <a id='ona' href="" target="_blank" onclick="getsel()">传值</a>
透過點擊時間為a標籤的href賦值就能夠實現
在b. php只需要得到參數即可
<?php $obj = $_REQUEST['obj']; echo $obj; ?>