No, you cannot do that. Not directly.
You should attach the name
attribute to the select
element. Then $_GET
will contain your_select_name=option_value
.
Then just correlate your $_GET['type']
and $_GET['value']
in the backend.
<form method="GET">
<select name="type">
<option value='artist'>Artist</option>
<option value='song'>Song</option>
</select>
<input type='text' name='value' />
</form>
<?php
echo $_GET['type']; // 'artist' or 'song'
echo $_GET['value']; // value of text input
P.S.: If you need to be strict about forming your URL, you can either provide two inputs and rig up a simple JS script that will hide the input not related to your select choice.
Actually, this idea calls for a little elaboration:
<form method="GET">
<select id='type'>
<option name='artist'>Artist</option>
<option selected name='song'>Song</option>
</select>
<input class='inp' id='song' type='text' name='song' />
<input class='inp' style='display:none' id='artist' type='text' name='artist' />
</form>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>
$('#type').change(function() {
$('.inp').val('').hide().prop('disabled', true); // hide and clear both inputs
$('#'+$('#type').val() ).prop('disabled', false).show(); //show input corresponding to your select
// Note the prop('disabled') calls - you want to disable the unused input so it does not add an empty key to your query string.
}
</script>