0

Hi everyone, If there are multiple hyperlinks in a webpage, How do I recognize them using java script. Also How do I store the content of the hyperlink in a variable , so that the data stored in the variable will be used the query a database and populate results in another webpage

For example there are many links in the webpage like this
<a href="update.php">text 1</a>.
<a href="update.php">text 2</a>
.
.
.
<a href="update.php">text N</a>

User can click any one of the hyperlinks in the webpage. If user clicks on hyperlink 'text4', text4 should be saved in a variable. Then pass the variable value to update.php , where database is queried using the statement "SELECT text4 from table sometable" and results are populated.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Airshow
0

Easiest way is to write the hrefs like this:

<a href="update.php?q=text1">text 1</a>
<a href="update.php?q=text2">text 2</a>

Then read $_GET['q'] in php (or the equivalent in other server-side languages) and build your SQL accordingly.

Airshow

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.