JS - 传递_GET变量onclick

时间:2016-04-30 16:03:36

标签: javascript php

以下代码段目前有效,但很难用$ _GET [&#39; group_type&#39;]替换group_type的数值,该值已从我需要传递到sales.php的上一页传递。< / p>

<select name="group_id" onclick="javascript:document.location.href='sales.php?group_type=2&group_id='+this.value;" 

由于

2 个答案:

答案 0 :(得分:1)

尝试:

<select name="group_id" onclick="javascript:document.location.href='sales.php?group_type=<?=$_GET['group_type']?>&group_id='+this.value;">

答案 1 :(得分:0)

你需要在php代码中注入它

<select name="group_id" onclick="javascript:document.location.href='sales.php?group_type=<?php echo  $_GET['group_type'] ?>'&group_id='+this.value;"