Omzy Posted December 23, 2008 Share Posted December 23, 2008 function goto(url) { var selection = document.getElementById('region'); if(selection.value != null) { document.location = url + document.getElementById('region').options[document.getElementById('region').selectedIndex].value; } } <a href="/directory/'.$index.'/" onclick="goto(this.href); return false">'.$cat[$index][2].'</a> 'region' is a drop down box (HTML SELECT). What the function does is append the current value of 'region' to the end of the URL specified in the 'a href'. It does this onclick (not onpage load). I was wondering could the same functionality be achieved using PHP? Perhaps using the header() function? Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 23, 2008 Share Posted December 23, 2008 No. Once the page is displayed, PHP has nothing to do with it. You could of course use AJAX, but that would be overcomplicating things (you would still use JavaScript) Quote Link to comment Share on other sites More sharing options...
Omzy Posted December 23, 2008 Author Share Posted December 23, 2008 Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.