Javascript not working

The Javascript I have on the Brain Function Testing page isn’t working correctly. It should totl up the numbers in that form, can you help me fix this?

  • Adam Czajczyk
    • Support Gorilla

    Hello Kristina,

    I hope you’re well today and thank you for your question!

    Can you please point me to the page in question (share an URL if it’s publicly available) and share you current JS code with me?

    You can share the code here marking it as a “code” (a < > icon in post editor toolbar) or post it on pastebin.com service and share a link to it with me here.

    I’ll then check it and see how I cold help you with it.

    Best regards,

    Adam

  • Kristina
    • Flash Drive

    It’s located on this page Brain Function Test

    The code is:

    <script language="javascript">
    $(document).ready(function(){

    $("input[name='row1[]']").change(function(){
    var row1=0;
    $("input[name='row1[]']").each(function(){
    row1= Number(row1)+Number($(this).val());
    });
    $("#row1total").val(row1);
    total =Number($("#row1total").val())+Number($("#row2total").val())+Number($("#row3total").val());
    $("#total").val(total);
    });

    $("input[name='row2[]']").change(function(){
    var row2=0;
    $("input[name='row2[]']").each(function(){
    row2= Number(row2)+Number($(this).val());
    });
    $("#row2total").val(row2);
    total =Number($("#row1total").val())+Number($("#row2total").val())+Number($("#row3total").val());
    $("#total").val(total);
    });

    $("input[name='row3[]']").change(function(){
    var row3=0;
    $("input[name='row3[]']").each(function(){
    row3= Number(row3)+Number($(this).val());
    });
    $("#row3total").val(row3);
    total =Number($("#row1total").val())+Number($("#row2total").val())+Number($("#row3total").val());
    $("#total").val(total);
    });

    });
    </script>
    <table border="0" cellspacing="2" cellpadding="1">
    <tbody>
    <tr>
    <th></th>
    <th>Almost Never (0)</th>
    <th>Sometimes (1)</th>
    <th>Often (2)</th>
    </tr>
    <tr>
    <td>Experiences aches and pains or headaches</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Become easily tired or have low energy</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Distracted easily</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Feel sad, unhappy</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Feel irritable, angry</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Difficulty falling asleep and/or staying asleep</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Forget names of people or things</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Racing thoughts</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Disorganized</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>My thinking ability seems slower than usual</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>My reaction time seems slower than normal</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>My concentration is worse than it used to be</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Anxiety or feeling nervous</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Trouble finding the right word or using the wrong word</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Tremors or shaking</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Loss of interest in some activities I previously found</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Trouble reading (cannot understand what you read)</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td style="height: 10px;" colspan="4"></td>
    </tr>
    <tr>
    <td align="right"><strong>Sum each column:</strong></td>
    <td align="center"><input id="row1total" name="row1total" readonly="readonly" size="4" type="text" /></td>
    <td align="center"><input id="row2total" name="row2total" readonly="readonly" size="4" type="text" /></td>
    <td align="center"><input id="row3total" name="row3total" readonly="readonly" size="4" type="text" /></td>
    </tr>
    <tr>
    <td style="height: 10px;" colspan="4"></td>
    </tr>
    <tr>
    <td align="right"><strong>Total score:</strong></td>
    <td colspan="3"><input id="total" style="margin-left: 40px;" name="total" readonly="readonly" size="12" type="text" /></td>
    </tr>
    <tr>
    <td style="height: 10px;" colspan="4"></td>
    </tr>
    </tbody>
    </table>

  • Adam Czajczyk
    • Support Gorilla

    Hello Kristina!

    Just to make sure: is there any specific way it should be adding up the values? I mean: totaling rows or columns or everything together?

    It’s not 100% clear from the code and I’d like to know that in order to be able to help you. Let me know please.

    Kind regards,

    Adam

  • Predrag Dubajic
    • Support

    Hi Kristina,

    I tested your code inside page content and WP doesn’t format it correctly so the script breaks and ti doesn’t work properly.

    What I did is moved it to shortcode and replaced dollar sign with jQuery, after that it worked fine.

    So what you need to do is add below code inside your child theme functions.php or as mu-plugin and then you can use [my_table] shortcode in your page.

    // Add Shortcode
    function custom_table_shortcode() { ?>

    <script language="javascript">
    jQuery(document).ready(function(){

    jQuery("input[name='row1[]']").change(function(){
    var row1=0;
    jQuery("input[name='row1[]']").each(function(){
    row1= Number(row1)+Number(jQuery(this).val());
    });
    jQuery("#row1total").val(row1);
    total =Number(jQuery("#row1total").val())+Number(jQuery("#row2total").val())+Number(jQuery("#row3total").val());
    jQuery("#total").val(total);
    });

    jQuery("input[name='row2[]']").change(function(){
    var row2=0;
    jQuery("input[name='row2[]']").each(function(){
    row2= Number(row2)+Number(jQuery(this).val());
    });
    jQuery("#row2total").val(row2);
    total =Number(jQuery("#row1total").val())+Number(jQuery("#row2total").val())+Number(jQuery("#row3total").val());
    jQuery("#total").val(total);
    });

    jQuery("input[name='row3[]']").change(function(){
    var row3=0;
    jQuery("input[name='row3[]']").each(function(){
    row3= Number(row3)+Number(jQuery(this).val());
    });
    jQuery("#row3total").val(row3);
    total =Number(jQuery("#row1total").val())+Number(jQuery("#row2total").val())+Number(jQuery("#row3total").val());
    jQuery("#total").val(total);
    });

    });
    </script>
    <table border="0" cellspacing="2" cellpadding="1">
    <tbody>
    <tr>
    <th></th>
    <th>Almost Never (0)</th>
    <th>Sometimes (1)</th>
    <th>Often (2)</th>
    </tr>
    <tr>
    <td>Experiences aches and pains or headaches</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Become easily tired or have low energy</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Distracted easily</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Feel sad, unhappy</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Feel irritable, angry</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Difficulty falling asleep and/or staying asleep</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Forget names of people or things</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Racing thoughts</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Disorganized</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>My thinking ability seems slower than usual</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>My reaction time seems slower than normal</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>My concentration is worse than it used to be</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Anxiety or feeling nervous</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Trouble finding the right word or using the wrong word</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Tremors or shaking</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Loss of interest in some activities I previously found</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td>Trouble reading (cannot understand what you read)</td>
    <td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>
    <td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>
    </tr>
    <tr>
    <td style="height: 10px;" colspan="4"></td>
    </tr>
    <tr>
    <td align="right"><strong>Sum each column:</strong></td>
    <td align="center"><input id="row1total" name="row1total" readonly="readonly" size="4" type="text" /></td>
    <td align="center"><input id="row2total" name="row2total" readonly="readonly" size="4" type="text" /></td>
    <td align="center"><input id="row3total" name="row3total" readonly="readonly" size="4" type="text" /></td>
    </tr>
    <tr>
    <td style="height: 10px;" colspan="4"></td>
    </tr>
    <tr>
    <td align="right"><strong>Total score:</strong></td>
    <td colspan="3"><input id="total" style="margin-left: 40px;" name="total" readonly="readonly" size="12" type="text" /></td>
    </tr>
    <tr>
    <td style="height: 10px;" colspan="4"></td>
    </tr>
    </tbody>
    </table>

    <?php }
    add_shortcode( 'my_table', 'custom_table_shortcode' );

    Best regards,

    Predrag

  • Predrag Dubajic
    • Support

    Hi Kristina,

    Ah, my bad, due to the way that shortcode outputs the content there’s different approach needed for HTML in code.

    Try using this instead:

    <?php
    // Add Shortcode
    function custom_table_shortcode() { ?>

    <script language="javascript">
    jQuery(document).ready(function(){

    jQuery("input[name='row1[]']").change(function(){
    var row1=0;
    jQuery("input[name='row1[]']").each(function(){
    row1= Number(row1)+Number(jQuery(this).val());
    });
    jQuery("#row1total").val(row1);
    total =Number(jQuery("#row1total").val())+Number(jQuery("#row2total").val())+Number(jQuery("#row3total").val());
    jQuery("#total").val(total);
    });

    jQuery("input[name='row2[]']").change(function(){
    var row2=0;
    jQuery("input[name='row2[]']").each(function(){
    row2= Number(row2)+Number(jQuery(this).val());
    });
    jQuery("#row2total").val(row2);
    total =Number(jQuery("#row1total").val())+Number(jQuery("#row2total").val())+Number(jQuery("#row3total").val());
    jQuery("#total").val(total);
    });

    jQuery("input[name='row3[]']").change(function(){
    var row3=0;
    jQuery("input[name='row3[]']").each(function(){
    row3= Number(row3)+Number(jQuery(this).val());
    });
    jQuery("#row3total").val(row3);
    total =Number(jQuery("#row1total").val())+Number(jQuery("#row2total").val())+Number(jQuery("#row3total").val());
    jQuery("#total").val(total);
    });

    });
    </script>
    <?php
    $return = '';
    $return .= '<table border="0" cellspacing="2" cellpadding="1">';
    $return .= '<tbody>';
    $return .= '<tr>';
    $return .= '<th></th>';
    $return .= '<th>Almost Never (0)</th>';
    $return .= '<th>Sometimes (1)</th>';
    $return .= '<th>Often (2)</th>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Experiences aches and pains or headaches</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Become easily tired or have low energy</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Distracted easily</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Feel sad, unhappy</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Feel irritable, angry</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Difficulty falling asleep and/or staying asleep</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Forget names of people or things</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Racing thoughts</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Disorganized</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>My thinking ability seems slower than usual</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>My reaction time seems slower than normal</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>My concentration is worse than it used to be</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Anxiety or feeling nervous</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Trouble finding the right word or using the wrong word</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Tremors or shaking</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Loss of interest in some activities I previously found</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td>Trouble reading (cannot understand what you read)</td>';
    $return .= '<td align="center"><input maxlength="1" name="row1[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row2[]" size="4" type="text" /></td>';
    $return .= '<td align="center"><input maxlength="1" name="row3[]" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td style="height: 10px;" colspan="4"></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td align="right"><strong>Sum each column:</strong></td>';
    $return .= '<td align="center"><input id="row1total" name="row1total" readonly="readonly" size="4" type="text" /></td>';
    $return .= '<td align="center"><input id="row2total" name="row2total" readonly="readonly" size="4" type="text" /></td>';
    $return .= '<td align="center"><input id="row3total" name="row3total" readonly="readonly" size="4" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td style="height: 10px;" colspan="4"></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td align="right"><strong>Total score:</strong></td>';
    $return .= '<td colspan="3"><input id="total" style="margin-left: 40px;" name="total" readonly="readonly" size="12" type="text" /></td>';
    $return .= '</tr>';
    $return .= '<tr>';
    $return .= '<td style="height: 10px;" colspan="4"></td>';
    $return .= '</tr>';
    $return .= '</tbody>';
    $return .= '</table>';
    return $return;
    }
    add_shortcode( 'my_table', 'custom_table_shortcode' );

    Shortcode is still the same:

    [my_table]

    Let us know how it goes.

    Best regards,

    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.