+ Start a Discussion
Ram Shiva KumarRam Shiva Kumar 

How to display the return value in VF page

Hi ,
 i have uplaoded the java script  file in staticresoure.  iam getting the pop up correctly. but  ih ave written the function in that file which will return multiplication of 2 numbres . Please suggest me how to display the value returned form the java script.

my ststic resource code is,

function popup() { alert("Hello World") }
function myFunction(a, b) {
    return a * b;

 And the vf code is,

<apex:page >


<apex:includeScript value="{!$Resource.jsss}"/>


<script type="text/javascript" >




Any body suggest me aboutthis.


Alexander TsitsuraAlexander Tsitsura

You can output result directly on the page, maybe put this value in a span tag. Note that script should execute after DOM completed loaded.
In my example bellow, the script run after span tag added to the page.
If something is not working, try to investigate errors in developer console(For open console in Google Chrome Press Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (Mac).
<span id="myspan"></span>
  var result = myFunction(4,5);
  var span = document.getElementById("myspan");
  var resultNode =  document.createTextNode('' + result);

  span.innerHTML = '';
If it helped you, then please select it the best answers it will help outer also.