JavaScript Function: function goto(url) { var selection = document.getElementById('region'); if(selection.value != null) { document.location = url + document.getElementById('region').options[document.getElementById('region').selectedIndex].value; } } Code (markup): <a href="/directory/'.$index.'/" onclick="goto(this.href); return false">'.$cat[$index][2].'</a> Code (markup): '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?
not really need to use header function check at my blog this refresh function http://www.crivionweb.com/phpblog/php-tutorial-function-to-refresh-a-page/ hope it's what u need
The simple workaround would be to instead of link use submit button. Visitor would send this form to you and using values from the form PHP would decide where to redirect him. I think there is no other way to do this.
But you see it isn't just that one hyperlink - there are about 50 hyperlinks which are in the menu. It's the way the site works and it works fine using JavaScript but it wont work on some mobile browsers.
I think onclick dosent work for dropdowns on mobile browsers..! not sure though.. you could display a button named go which calls goto().. That should work on js supported mobile browsers.
No since javascript is a client side programming it can't be done using PHP you would have to recode it for in a similar way for it to work for mobile
This is funny code. Make use of DOMDocument->loadHTML() in PHP scripting. Try yourself this code against JavaScript