I am trying to update a database from an onClick procedure inside an anchor.
<a name=“fs1” onClick="updateArea1();"></a>
I am struggling with the function for updateArea1 as I'm not really sure how I can pass the name "fs1" from the anchor and update the database from a script process.
I would essentially like the database to be updated like this: UPDATE row WHERE id = 1 WITH (name_from_anchor)
However... the variable does not HAVE to come from the name tag. It could be referenced in the parenthesis of the function like this if it's easier.
<a onClick="updateArea1(fs1);"></a>
Any help would be greatly appreciated.
-- UPDATED --
LAUNCH.PHP
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="apple-mobile-web-app-capable" content="yes" />
<script src="includes/scripts/jquery-2.0.3.min.js"></script>
<script>
function updateArea1(el) {
$.post("includes/db_update.php", $("#console").serialize());
}
</script>
</head>
<body>
<a name="fs1" onClick="updateArea1(this.name);"></a>
<a name="fs2" onClick="updateArea1(this.name);"></a>
</body>
</html>
DB_UPDATE.PHP
<?php
include 'db_connect.php';
$area1= mysqli_escape_String($con,$_POST[]);
$query = "UPDATE previewState SET selected='".$area1."' WHERE id='1';";
mysqli_query($con,$query);
mysqli_close($con);
?>