• Resolved igonro

    (@igonro)


    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. Reason: code missing
Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @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.