To achieve this functionality, utilizing AJAX is the recommended approach. While it's possible to accomplish the task using vanilla Javascript, it tends to result in messy code. Personally, I always opt for using a library like jQuery for smoother implementation. With jQuery, the code would look like this:
<input type="button" id="sendmac" value="Send MAC Address">
And the accompanying jQuery script would be:
$(function() {
$("#sendmac").click(function() {
document.macaddressapplet.setSep( "-" );
$.post("savemacaddress.php", {
getMacAddress: document.macaddressapplet.getMacAddress()
});
});
});
For the PHP script savemacaddress.php:
<?php
$addr = $_POST['savemacaddress'];
$addr = mysql_real_escape_string($addr);
$sql = "INSERT INTO macaddress ('$addr')";
mysql_connect(...);
mysql_query($sql);
?>
It is assumed that PHP is being used for this scenario.