Title: Error when using jQuery().html() several times
Last modified: January 30, 2021

---

# Error when using jQuery().html() several times

 *  Resolved [igonro](https://wordpress.org/support/users/igonro/)
 * (@igonro)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/error-when-using-jquery-html-several-times/)
 * Hi,
 * I have a form in which at the end I have an “HTML Content” field with the following
   code:
 *     ```
       <ul>
       	<span id="span-1"/>
       	<span id="span-2"/>
       	<span id="span-3"/>
       	<span id="span-4"/>
       	<span id="span-5"/>		
       </ul>
       ```
   
 * Just before that HTML field, I have some “Calculated Fields” with this code (
   all are very similar):
 *     ```
       (function(){
       	let result;
       	if(fieldname4 === 'Mensual') result = (fieldname2 + 12 * fieldname5 * fieldname3);
       	if(fieldname4 === 'Anual') result = (fieldname2 + fieldname5 * fieldname3);
   
       	let html_str = "<li><b>some random HTML text</b></li>";
       	jQuery('#span-1').html(html_str);
       	return result;
       })();
       ```
   
 * But when I press the “Submit” button, it only shows up the first “#span-1” content,
   I can’t have the following “#span-X” content showing. If I comment the “#span-
   1” jQuery line, then the “#span-2” content is showing up.
 * Do you have any idea of what could be the problem? I’ve already searched in the
   other posts, but I didn’t find any solution. Thanks!
    -  This topic was modified 5 years, 4 months ago by [igonro](https://wordpress.org/support/users/igonro/).
      Reason: code missing

Viewing 1 replies (of 1 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/error-when-using-jquery-html-several-times/#post-13980084)
 * Hello [@igonro](https://wordpress.org/support/users/igonro/)
 * The correct would be:
 *     ```
       <ul>
       	<li id="span-1"></li>
       	<li id="span-2"></li>
       	<li id="span-3"></li>
       	<li id="span-4"></li>
       	<li id="span-5"></li>		
       </ul>
       ```
   
 * and edit the equation as follows:
 *     ```
       (function(){
       	let result;
       	if(fieldname4 === 'Mensual') result = (fieldname2 + 12 * fieldname5 * fieldname3);
       	if(fieldname4 === 'Anual') result = (fieldname2 + fieldname5 * fieldname3);
   
       	let html_str = "<b>some random HTML text</b>";
       	jQuery('#span-1').html(html_str);
       	return result;
       })();
       ```
   
 * Best regards.

Viewing 1 replies (of 1 total)

The topic ‘Error when using jQuery().html() several times’ 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/error-when-using-jquery-html-several-times/#post-13980084)
 * Status: resolved