Reputation: 23
I have searched many solutions and almost all over the internet but found no answer.
I am having a form like:
<form action="index.php" method="get">
<select id="store" type="text" name="s">
<option valA="value1" valB="value2">Selection 1</option>
<option valA="value3" valB="value4">Selection 2</option>
</select>
<input id="submit" type="submit" value="Submit" />
</form>
This form is extended via PHP with MySQL which takes valA and valB from database for each "Selection" in while loop and generate form with that form (given above).
I know that sending it via POST will reload my website with value given by value name. But I need to do it with two values.
So my link when I select one of the options will be:
http://mywebsite.com/index.php?valA=value1&valB=value2
Form is still active every time website reloads, so when I choose another option, I want to change it with submit and change URL.
Everything I found is to use multiple option and send two of them at the same time, but I have no multiple selection, but one selection with many parameters each (for me - two).
Is it possible to do it via HTML/Form, or I need to use PHP, but how?
I need to reload website - not change it only, because based on valA and valB website will load datatables script based on it and will produce table from database one of the values is just a key to table, another to database.
Upvotes: 0
Views: 466
Reputation: 54841
Maybe you can join your required values with some delimiter, for example:
<select id="store" type="text" name="s">
<option value="value1:value2">Selection 1</option>
<option value="value3:value4">Selection 2</option>
</select>
Your url becomes:
http://mywebsite.com/index.php?s=value1:value2
On server side you can:
$parts = explode(':', $_GET['s']);
Upvotes: 1
Reputation: 139
You will need javascript to achieve that without php
If your php is whats receiving the call then why don't you have a value seperated by a delmiter value="value1|value2"
then in your php I would do the following
$values = explode("|",$_GET['s']);
then you have $values[0] and $values[1] - containing the two values
Upvotes: 0