-1
<form name="from" id="from">
<input type="text" name="x" onkeyup="Get_Value()"/>
<input type="text" name="y" onkeyup="Get_Value()"/>
</form>                                                     

<script type="text/javascript">
      function Get_Value() {
         var x = Number(document.from.x.value);
         var y= Number(document.from.y.value);
         var total=x+y;
         document.getElementById("total").innerHTML =total;
        }
</script>
<?php
$total='<div id="total"></div>'; 
echo $total;
?>

When I execute this and put x=10, y=20 then it shows me 30 to the browser. Its fine.

When I save it the DB then it storing <div id="total">30</div>. But I need the 30 only.

Though the title of the question is a common one, I didn't found my answer.

What should I do now?

Litle Dev
  • 474
  • 1
  • 5
  • 18

1 Answers1

0

If you want send data from PHP that would be accessable in JS, then you can use

<script type="text/javascript">
      function Get_Value(x, y) {
          var total=x+y;
          document.getElementById("total").innerHTML =total;
      }

      Get_Value(<?php echo 10; ?>, <?php echo 20; ?>);
</script>

If you have, any variable , then replace echo 10 with your choice.

timiTao
  • 1,417
  • 3
  • 20
  • 34