<script>
var publicationid = 1;
function addPublication()
{
var obj = document.getElementById("pub");
var data = obj.innerHTML;
if (publicationid == 2){

}else {

data += "<h1 style = 'color:white;'>test</h1>";

obj.innerHTML = data;
publicationid++;

<?php
$updatePublicationsNewCounter++;
?>
}
function subtractPublication()
{
var obj = document.getElementById("pub");
var data = obj.innerHTML;
data = "" ;
obj.innerHTML = data;
publicationid = 1;
<?php
$updatePublicationsNewCounter = 1;
?>
}
</script>

only the first one works when I take off the second one.

How can I recopy the first script to be used again on a different div