I am trying to increment a php variable in a javascript function:
function border(){
  <?php $var_drafts_display=0; ?>;
  for(var i=0; i<5; i++)
     {
    <?php ++$var_drafts_display ; ?>;
     }
  var final_num='<?php  echo $var_drafts_display; ?>';
  alert(final_num);
  }
But the php variable gets incremented only once i.e alert(final_num) shows 1. I know php is server side program and javascript is client side program, is that the main problem why php variable is not getting incremented. Also, I am not able to figure out why it is getting incremented only once.
 
     
     
     
    