#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    4
    Rep Power
    0

    javascript and arrays


    I am using smarty sections to loop through an array and output html. My array is built up like this:

    <tr>
    {section name=sec1 loop=$inner}
    {if $inner[sec1].F_B_ID ne $inner[sec1.index_prev].F_B_ID}
    <tr>
    <td> &nbsp;&nbsp;{$inner[sec1].F_AC_Code}</td>
    <td> <input type="hidden" name="FACCODE[{$smarty.section.sec1.iteration}]" value="{$inner[sec1].F_AC_Code}"></td>
    <td> &nbsp;&nbsp;{$inner[sec1].F_B_ID}</td>
    <td> <input type="hidden" name="FBID[{$smarty.section.sec1.iteration}]" value="{$inner[sec1].F_B_ID}"></td>
    <td> &nbsp;&nbsp;{$inner[sec1].PayDate}</td>
    <td> <input type="hidden" name="PayDate[{$smarty.section.sec1.iteration}]" value="{$inner[sec1].PayDate}"></td>
    <td> &nbsp;&nbsp;{$inner[sec1].CreditDebit}</td>
    <input type="hidden" name="CreditDebit[{$smarty.section.sec1.iteration}]" value="{$inner[sec1].CreditDebit}"></td>
    <td> &nbsp;&nbsp;{$inner[sec1].Method}</td>
    <input type="hidden" name="Method[{$smarty.section.sec1.iteration}]" value="{$inner[sec1].Method}"></td>
    <td> &nbsp;&nbsp;{$inner[sec1].Amount}</td>
    <input type="hidden" name="Amount[{$smarty.section.sec1.iteration}]" value="{$inner[sec1].Amount}"></td>
    <td> &nbsp;&nbsp;{$inner[sec1].Notes}</td>
    <td> <input type="checkbox" name="check" value="{$inner[sec1].Amount}" onclick="AmountCalc(pay_amount)" checked></td>
    </tr>
    {/if}
    {/section}
    </tr>

    In the javascript I want to output some of the array items - actually when a checkbox is checked.

    I am using:

    for (var _i=0;_i<document.BoBankPayIn.check.length;_i++)
    {
    if (document.BoBankPayIn.check[_i].defaultChecked)
    {
    _defaultChecked = " "+_i;
    }
    if (document.BoBankPayIn.check[_i].checked)
    {
    _st+=document.BoBankPayIn.check[_i].value;
    _st+="<br>";
    _st+="document.BoBankPayIn.FACCode[" + _i + "].value");
    //alert("document.BoBankPayIn.FACCode[" + _i + "].value");
    //pay_amount.value = parseFloat(pay_amount.value) + parseFloat(document.BoBankPayIn.check[_i].value);
    //IDs[_i] = document.BoBankPayIn['Amounts[_i]']
    }
    }

    Is the line
    _st+="document.BoBankPayIn.FACCode[" + _i + "].value");
    correct? All I output is the text with the correct iteration but what I would like is the actual value.

    Cheers
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Get rid of all the quotes and the +'s and it should work.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    4
    Rep Power
    0

    Angry Nope - still doesn't work


    No, removing the quotes and +'s and even the stray ')' still gives a javascript error. The changed line now looks like:

    _st+=document.BoBankPayIn.FACCode[_i].value;

IMN logo majestic logo threadwatch logo seochat tools logo