function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Surya V 2Surya V 2 

How to include javascript in static resource? I have javascript code in vf paga, but i need to add javascript code aone in vf page through static resource.

Hi All,
How to call javascript in visualforce page using static resource?
 
Trying to include javascript in visualforce but i'm not getting proper output. Please find the below code.
This code is woking fine now, but i need to call javascript alone in visualforce page through static resource.
I need to call highlighted javascript code in static resource.
===================================================================================
<apex:page standardController="Inquiry__c" sidebar="false">
<head>
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"></meta>
</head>
<!-- <apex:includeScript value="{!URLFOR($Resource.JSforce)}" /> Static Resource or Direct Link Below -->
<!--<script src="//cdnjs.cloudflare.com/ajax/libs/jsforce/1.4.1/jsforce.min.js"></script>-->  <!-- Direct Link For the Script File  -->
<script src="{!$Resource.jsforce_30}"></script>
<!--<script type="text/javascript" src="https://www.google.com/jsapi"></script>-->
<script src="{!$Resource.jsapi_30}"></script>
<apex:outputPanel >
<div>
<table>
<tr>
<td>
    <div id="barChart" style="width: 460px; height: 250px;"></div></td>
  <td>  <div id="pieChart" style="width: 450px; height: 250px;"></div></td>
  </tr>
    </table>
</div>
</apex:outputPanel>
<script>
var cArr = [];
var cArr1 = [];
var conn = new jsforce.Connection({ accessToken: '{!$Api.Session_Id}' });
conn.query("select  Status,count(id),whatid from Task where whatid= '{!Inquiry__c.id}' group by Status,whatid ", function(err, res) {
if (err) { return console.error(err); }
  
   for(i = 0; i < res.records.length; i++)
   {
        cArr.push(res.records[i].Status);
        cArr1.push(res.records[i].expr0);
      
   }
});
  
google.load("visualization", "1.1", {packages:["bar", "corechart"]});
google.setOnLoadCallback(drawStuff);
      
function drawStuff() {
       //adding columns to Google DataTable
         var data = new google.visualization.DataTable();
            data.addColumn('string','Status');
            data.addColumn('number','Total Task');
         
for(i = 0; i < cArr1.length; i++)
    data.addRow([cArr[i], cArr1[i]]);
    
var options = {
        
        bars: 'vertical', // Required for Material Bar Charts.
        axes: {
            x: {
              0: { side: 'left', label: 'Status'}
            },
            y: {
              0: { label: 'Number Of Task'} 
            }
          },
          bar: { groupWidth: "5%" }
      };
        
//-----Drawing Charts-----
//BarChart
var chart = new google.charts.Bar(document.getElementById('barChart'));
        chart.draw(data, options);
        
 
           
      };
      
</script>
</apex:page>
=================================================================================
 
Thanks in advance.