Reputation: 2676
Very basic seeming PHP question here... I have a page to which I'm already passing a value, e.g.: Product.php?type=apples
Now I want a drop down form to pass another value, so i'd end up with something like: Product.php?type=apples&cost=cheap
I've tried putting these in a form that looks like:
<form action="./Product.php" method="POST">
<small>View:</small>
<select name="cost" onchange="this.form.submit();">
<option>Choose Metrics</option>
<option value="cheap&type=<?php echo $typeID?>"></option>
to keep the type variable and add the "cost" variable, but the ampersand gets decoded in the URL string.
Am I going about this the wrong way?
Thanks very much.
Upvotes: 1
Views: 406
Reputation: 100205
<form action="./Product.php" method="GET"> <input type="hidden" name="type" value="your_type_value" /> <select name="cost" onchange="this.form.submit();"> <option>Choose Metrics</option> <option value="cheap"></option>
Upvotes: 0
Reputation: 24815
First of all, you need to change the method from POST
to GET
.
Secondly, a second variable, needs a second input field. You could use a hidden field for that, or let the user choose it. (Or do javascript manipulation)
Hidden field
<input type="hidden" id="type" name="type" value="cheap">
This can be achieved with JavaScript too ofcourse!
Upvotes: 1