Forum Moderators: open
<a href="test.php?id=20">Click me</a>
btw, Welcome to WebmasterWorld! :)
I know how to link directly using the id as you showed in the example, however, I would like to have it were the hyperlink pulls the id from the url dynamically so I don't have to code all the pages with the id# in the link manually.
Any ideas would be appreciated...
Thanks Much!
I have a page that when loaded it loads with a page id so some SQL info can be loaded. There is a survey that is page id specific that submits the results to the database that the page originally pulls. So for example, test.php?id=20 will pull the results for the SQL info for that input - I want a dynamic link on that page that when I click it it will open the survey with the following:
survey.php?id=20
I can hard code the link to bring the specific survey but I will have several different pages that I would like to page id and allow the hyperlink to pull the survey page id.
Hope that makes a little more sense. If there's a different way of doing this or another forum to post I will gladly do so, and I appreciate the assistance thus far.
You want to create a link, which doesn't exist on the page - ./survey.php?id=20. So you createElement("a"), and the href attribute would be "./survey.php?id" +top.location.search.substring(1).split("="). Then you pick the element where you want it to appear, and append. var placeHere = "heregoes"; [1][edited by: tedster at 2:41 am (utc) on Feb. 22, 2008]
var elmt = document.createElement("a");
elmt.href = "./survey.php?id=" +top.location.search.substring(1).split("=")[1];
elmt.innerHTML = "click here";
document.getElementById(placeHere).appendChild(elmt);
[edit reason] switch to example.com - it can never be owned [/edit]