sumwonlost
sumwonlost

Reputation: 23

JS - pass _GET variable onclick

The following snippet currently works, however having difficulties replacing the numeric value for group_type with $_GET['group_type'] which has been passed from previous page which I require to be passed onto sales.php.

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

Thanks

Upvotes: 0

Views: 229

Answers (2)

Bill Martin
Bill Martin

Reputation: 456

Try:

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

Upvotes: 1

adrianj98
adrianj98

Reputation: 573

You need to inject it in the php code

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

Upvotes: 0

Related Questions