Home > Backend Development > PHP Tutorial > About passing value in php page

About passing value in php page

巴扎黑
Release: 2016-11-12 10:00:46
Original
1231 people have browsed it

PHP page value transfer

Do not use a form to transfer the value of the drop-down box. In fact, it is very simple to obtain it with js. See the code below

Php code

<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(&#39;ona&#39;);  
    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>
Copy after login

Pass value

This can be achieved by assigning a value to the href of the a tag at the click time

You only need to get the parameters in b.php

Php code

<?php  
$obj = $_REQUEST[&#39;obj&#39;];  
echo $obj;  
?>
Copy after login


Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template