If you are trying to pass anchor tag value in html to JavaScript, it is very easy. Here we are explaining, How to pass anchor tag value in JavaScript function or How to pass multiple parameters to javascript function. You can do that. It is possible in Javascript function.
First of all, we will pass a value by onclick function with user defined function in anchor tag <a>
See below example:
<a href='#' onclick='send(2205)'>Click Here</a>
After that we will use user define send() function in Javascript for sending value to javascript function also we will send anchor tag value in page url by redirection in Javascript for getting this value in PHP.
See below example:
<script>
function send(value) {
var orderID = parseInt(value);
var status = “complete”;
window.location = "?status=" + status + "&orderID=" + orderID;
}
</script>
Now, we will use $_GET PHP superglobal variables for retrieving url variable.
See below example:
<?php
if (isset($_GET['orderID'])) {
$anchorValue = $_GET['orderID'];
echo 'This is anchor tag value '.$anchorValue;
}
else
{
$anchorValue = "<br />no anchor value found!";
echo $anchorValue;
}
?>