3 dimensional array assigned to smarty pass to javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jacob Siemaszko
    New Member
    • Mar 2012
    • 1

    3 dimensional array assigned to smarty pass to javascript

    In my program I want to use a 3 dimensional array to read out and compare the url data. That doesn't matter, but the main thing is, i pass a 3 dimensional array to a template as {test} so it has the following array structure a numeric array, where i pot a associative array in, and there inside is a another numeric array.

    $test[0]['name'][0]

    Now I want to use javascript to read out the length of the different array's and also the variables but since I cant get it work, can someone help my please? i ll be greatfull
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Because of smarty's default curly bracket ({}) tags, you need to use the smarty {literal} tag to echo out your variable value to a javascript one. Remember javaScript is client side, server does not execute it like smarty and php, the user's computer browser executes it.

    You can also print it out to a hidden field and read it using javascript. document.getEle mentById('hidde nFieldsID').val ue. or using jquery: $('#hiddenField ID').val()

    Good luck,

    Dan

    Comment

    Working...