Folks,
Greetings!
When the visitor select any option from the dropdown Menu, i want to capture that value with $_GET['q'], and it should reload the page also so that i can grab the valur of Q variable.
Right now what is happening is, when i select any Value, it just does not refresh and i am not able to passon the Q value as well, looks like its only Client side and can not even execure any PHP Data grabbing function.
here is the code i am using:
<select id="items" onselect="javascript:reloadPage(this)">
<?php foreach($searchWords as $lolachild): ?>
<option value="<?php
echo $host.str_replace(' ','-',$lolachild).'开发者_开发知识库.html'; ?>"><?php echo ucwords($lolachild); ?> </option>
<?php endforeach; ?>
</select>
<script type="text/javascript"><!--
function reloadPage(id) {
document.location.href = location.href + '?id=' + id.value;
}
--></script>
Can someone please help me with this, please?
Cheers Natasha Thomas
You want the onchange event, not onselect.
There will be other issues though with your script though.
The reloadPage function is adding to the location.href irregardless of if there is already a query string. I'd suggest reconstructing it, see window.location.
You will need to reselect the value they changed it to. If the change the select box to the second option, your page will reload and the first option will be selected again.
精彩评论