plutomed Posted September 1, 2007 Share Posted September 1, 2007 Is there a way to do this??? Quote Link to comment Share on other sites More sharing options...
php_tom Posted September 1, 2007 Share Posted September 1, 2007 You didn't really describe exactly what you want to do... I'm guessing you have something like this in mind (?): <script> var get_variable = '<?php echo $_GET['variable']; ?>'; alert(get_variable); </script> If not, please explain more. Quote Link to comment Share on other sites More sharing options...
plutomed Posted September 1, 2007 Author Share Posted September 1, 2007 I know how to do it that way I guess I could do it like that. Is there no way to do it with javascript then coz It's in the *.js file at the moment. Quote Link to comment Share on other sites More sharing options...
php_tom Posted September 1, 2007 Share Posted September 1, 2007 I see... I found this somewhere in the vast cavern of knowledge we call the web: <script> function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } alert('Query Variable ' + variable + ' not found'); } </script> Now make a request to page.html?x=Hello <script> alert( getQueryVariable("x") ); </script> Note that it only works with GET, not POST. Hope that helps. Quote Link to comment Share on other sites More sharing options...
plutomed Posted September 1, 2007 Author Share Posted September 1, 2007 Yea I thought about doing it with the split but I thought again because I need a specific one out of the URL. I think I will just put the JS at the top of the page and use php. Thanx anyways. 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.