Home > Article > Backend Development > About passing value in php page
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('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>
31c2ecf993e6997a251f8e6a88381581Pass value5db79b134e9f6b82c0b36e0489ee08ed
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['obj']; echo $obj; ?>