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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.