Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smarty template vars and Javascript functions

    Hi there.

    I've got a smarty loop (template side):

    {section name=index loop=$productData}
    <tr>
    <td>{$productData[index].short}</td>
    <td>{$productData[index].Omschrijving}</td>
    <td>{$productData[index].Verkoopprijs}</td>
    <td>
    {$productData[index].Hoofdgroep}
    (<a href="#" onclick="editProduct('{$productData[index]}');">Wijzig</a>)
    </td>
    <td><input type="checkbox" name="proI_{$productData[index].id}" id="PRO_{$productData[index].id}"></td>
    </tr>
    {/section}

    Now I whould like to send the array {$productData[index]} to my Javascript function. But when I check my Javascript function editProduct(); using Firebug... the received parameter array is empty!

    What to do, what to do?

  • #2
    New Coder
    Join Date
    Jul 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think I found the solution.

    Doesn't look very pretty, but it works:

    <td>
    {$productData[index].Hoofdgroep}
    (<a href="#" onclick="getData();">Wijzig</a>)
    {literal}
    <script type="text/javascript">
    function getData() {
    var productData = new Object();
    productData.Id = '{/literal}{$productData[index].id}{literal}';
    productData.Omschrijving = '{/literal}{$productData[index].Omschrijving}{literal}';
    editProduct(productData);
    }
    </script>
    {/literal}
    </td>
    Last edited by Codestar; 08-09-2007 at 10:58 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •