Home > Backend Development > PHP Tutorial > js获取php(ecshop smarty模板)数组元素值,该如何解决

js获取php(ecshop smarty模板)数组元素值,该如何解决

WBOY
Release: 2016-06-13 12:35:08
Original
1526 people have browsed it

js获取php(ecshop smarty模板)数组元素值
最近修改PHP东西(ecshop),遇到一个问题,诚恳求助各位高手:
1.在php页面里利用smarty模板赋值,部分代码如下:
 
    while ($row = $db->FetchRow($res))
    {
     if($cur==null)
     $cur=$row['template_id'];
     $modelrow[$row['template_id']]=$row['template_id'];
     $modelcontent[$row['template_id']]=trim($row['template_content']);     
     $modelplates[$row['template_id']]=$row['template_subject']." -$row[content_category]-".$row['template_subject_second'];
 //  echo         $modelcontent[$row['template_id']];
   
    }
$smarty->assign('cur', $cur);
$smarty->assign('modelrow', $modelrow);
$smarty->assign('modelplates', $modelplates);
$smarty->assign('modelcontent',$modelcontent);
/*end*/

$modelcontent 数组传递到前台的dwt模板中 在js函数中:
1、显示获取一个变量值temp=$("#temp").val(); (这个变量值为1、2、3之类的,获取没有问题。)
2、var a='{$modelcontent.temp}';第二步利用变量获取$modelcontent的一个元素值,但是为空,不知道怎么样才能获取到;我在测试的时候var a='{$modelcontent.1}'获取数组下标为1的还是能够获取到。
现在问题是怎么根据已知变量获取到数组对应下标值?还是有其他解决的办法,谢谢各位!

ecshop smarty php
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template