Title: Insert FieldValue in HTML Content function
Last modified: August 31, 2016

---

# Insert FieldValue in HTML Content function

 *  Resolved [dulicanazi](https://wordpress.org/support/users/dulicanazi/)
 * (@dulicanazi)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/insert-fieldvalue-in-html-content-function/)
 * i have my html content with a function in it how can i get values in my function
   from a specified fieldname ?
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [dulicanazi](https://wordpress.org/support/users/dulicanazi/)
 * (@dulicanazi)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/insert-fieldvalue-in-html-content-function/#post-7049425)
 *     ```
       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](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/insert-fieldvalue-in-html-content-function/#post-7049448)
 * 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](https://wordpress.org/support/users/dulicanazi/)
 * (@dulicanazi)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/insert-fieldvalue-in-html-content-function/#post-7049501)
 * 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](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/insert-fieldvalue-in-html-content-function/#post-7049502)
 * Hi,
 * You simply should close the value between symbols: “[“, “]” as follows:
 * `['Work', [jQuery('.myclass input').val()] ],`
 * Best regards.
 *  Thread Starter [dulicanazi](https://wordpress.org/support/users/dulicanazi/)
 * (@dulicanazi)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/insert-fieldvalue-in-html-content-function/#post-7049505)
 * 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](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/insert-fieldvalue-in-html-content-function/#post-7049508)
 * 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:
 * [http://cff.dwbooster.com/customization](http://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.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/insert-fieldvalue-in-html-content-function/#post-7049508)
 * Status: resolved