redgunner Posted August 30, 2010 Share Posted August 30, 2010 :shrug: Is it possible to pass variables through #anchors for example <a href="#edit?id=xxx"> and if so how? Quote Link to comment https://forums.phpfreaks.com/topic/212054-anchors-and-variables/ Share on other sites More sharing options...
Namtip Posted August 30, 2010 Share Posted August 30, 2010 Looks like nobody knows, so I'm going to help out. lucky you! These links says you can and has some information about how to do it: http://www.coderanch.com/t/111999/HTML-JavaScript/anchor-tag-passing-variable http://www.ahfb2000.com/webmaster_help_desk/showthread.php?t=7579 I'm afraid I don't know how to do it but at least 2 examples in from the links above (that I don't understand). Please see my signature warning. Quote Link to comment https://forums.phpfreaks.com/topic/212054-anchors-and-variables/#findComment-1105176 Share on other sites More sharing options...
wildteen88 Posted August 30, 2010 Share Posted August 30, 2010 The links Namtip suggested will not help you. :shrug: Is it possible to pass variables through #anchors for example <a href="#edit?id=xxx"> and if so how? No, it is not possible to send variables after the # sign. Anything after the # will not be sent in the HTTP request to the server. Quote Link to comment https://forums.phpfreaks.com/topic/212054-anchors-and-variables/#findComment-1105184 Share on other sites More sharing options...
redgunner Posted August 30, 2010 Author Share Posted August 30, 2010 How could I get round this problem? Quote Link to comment https://forums.phpfreaks.com/topic/212054-anchors-and-variables/#findComment-1105185 Share on other sites More sharing options...
litebearer Posted August 30, 2010 Share Posted August 30, 2010 random thoughts... 1. create a variable that is combination of the anchor tag name and the id (ie anchor_name ."|" . id) 2. use normal url variable pass - using the comboname as the data being passed 3. at the target page break the combo back to two variables 4. use <body onLoad="window.location = '#anchor_name'"> in your target page Quote Link to comment https://forums.phpfreaks.com/topic/212054-anchors-and-variables/#findComment-1105190 Share on other sites More sharing options...
wildteen88 Posted August 30, 2010 Share Posted August 30, 2010 You can code your link as <a href="file.php?id=xxx#edit">Edit</a> Which will work fine, it'll pass the id of XXX to your PHP script and go to the anchor named as edit. Just you cant code it as <a href="file.php#edit?id=xxx">Edit</a> Quote Link to comment https://forums.phpfreaks.com/topic/212054-anchors-and-variables/#findComment-1105192 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.