Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter dulicanazi

    (@dulicanazi)

    function drawChart() {
            var data = google.visualization.arrayToDataTable([
              ['Task', 'Hours per Day'],
              ['Work',    'fieldname1'],
              ['Eat',      2],
              ['Commute',  2],
              ['Watch TV', 2],
              ['Sleep',    7]
            ]);
    
            var options = {
    backgroundColor: 'transparent',
              title: 'My Daily Activities'
            };
    
            var chart = new google.visualization.PieChart(document.getElementById('piechart'));

    i want to insert the field value here [‘Work’, ‘fieldname1’], how can i do that

    Plugin Author codepeople

    (@codepeople)

    Hi,

    There are two options:

    First option, if there is only one form in the webpage, and you want get its value, you can modify the snippet of code:

    ['Work', 'fieldname1'],

    as follows:

    ['Work', jQuery('#fieldname1_1').val()],

    Second option, assigns a class name to the fieldname1 field, for example: myclass

    Note: The class names are assigned to the fields through the attribute: “Add Css Layout Keywords”

    and then, get it’s value as follows:

    ['Work', jQuery('.myclass input').val()],

    Best regards.

    Thread Starter dulicanazi

    (@dulicanazi)

    I tried it but not working the … if i leave only one value in the function it will work and show me 100% and the actual field value but if i got more than 1 value it will not work anymore … what could be the problem if you can help me

    Plugin Author codepeople

    (@codepeople)

    Hi,

    You simply should close the value between symbols: “[“, “]” as follows:

    ['Work', [jQuery('.myclass input').val()] ],

    Best regards.

    Thread Starter dulicanazi

    (@dulicanazi)

    Still not working … this is the complete code from my HTML content field

    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
          function drawChart() {
    
            var data = google.visualization.arrayToDataTable([
              ['Task', 'Hours per Day'],
              ['Sitting',     [jQuery('.wsval input').val()]],
              ['Running',    [jQuery('.testval input').val()]]
            ]);
    
            var options = {
              title: 'My Daily Activities'
            };
    
            var chart = new google.visualization.PieChart(document.getElementById('piechart'));
    
            chart.draw(data, options);
          }
        </script>
    <div id="piechart"></div>

    And at onClick action button i have set up this:

    google.charts.load('current', {'packages':['corechart']});
    google.charts.setOnLoadCallback(drawChart);

    This is the complete code example from google:

    <html>
      <head>
        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
        <script type="text/javascript">
          google.charts.load('current', {'packages':['corechart']});
          google.charts.setOnLoadCallback(drawChart);
          function drawChart() {
    
            var data = google.visualization.arrayToDataTable([
              ['Task', 'Hours per Day'],
              ['Work',     11],
              ['Eat',      2],
              ['Commute',  2],
              ['Watch TV', 2],
              ['Sleep',    7]
            ]);
    
            var options = {
              title: 'My Daily Activities'
            };
    
            var chart = new google.visualization.PieChart(document.getElementById('piechart'));
    
            chart.draw(data, options);
          }
        </script>
      </head>
      <body>
        <div id="piechart" style="width: 900px; height: 500px;"></div>
      </body>
    </html>

    I dont know why is not working … i am doing something wrong ?

    Plugin Author codepeople

    (@codepeople)

    Hi,

    First, in the example the value of ‘work’ is a number and not an array.

    Second, the code:

    google.charts.load('current', {'packages':['corechart']});
    google.charts.setOnLoadCallback(drawChart);

    should be into a function, and call it from the onclick event of the button:

    function myCode(){
    google.charts.load('current', {'packages':['corechart']});
    google.charts.setOnLoadCallback(drawChart);
    }

    The onclick event would be simply: myCode();

    Furthermore, I don’t know if the class names: wsval and testval, have been assigned correctly to the fields, and the values of the fields at runtime with the piece of code you sent me.

    If you are needing a custom coding service to integrate the form with a third party code, please, requests a custom coding service through my private webpage:

    https://cff.dwbooster.com/customization

    Best regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Insert FieldValue in HTML Content function’ is closed to new replies.