I'm trying create a module. In this module, i have an array (ex. [0]-> company1, [1]-> company2...), and i want send this array to a function in javascript.
So, in the template file, add:
Code
<!--[pnpageaddvar name="javascript" value="modules/nameModule/pnjavascript/file.js"]-->
Later
Code
<select name="Tipo" id="Tipo" onchange="Programador_cargaCmb(<!--[ $comp ]-->,<!--[ $categ ]-->)">
<option value="empresa">Empresa</option>
<option value="categoria">CategorÃa</option>
</select>
<option value="empresa">Empresa</option>
<option value="categoria">CategorÃa</option>
</select>
$comp and $categ are arrays.
File JS:
Code
function Programador_cargaCmb(empresas, categorias)
{
var sel;
sel = document.frmFilter.Tipo[document.frmFilter.Tipo.selectedIndex].value;
if (sel == "empresa"){
document.frmFilter.cmb.length = empresas.length;
document.frmFilter.txt.value = empresas.length;
for (i=0;i<empresas.length;i++){
document.frmFilter.cmb.options[i].value = empresas[i];
document.frmFilter.cmb.options[i].text = empresas[i];
}
}
...
...
}
{
var sel;
sel = document.frmFilter.Tipo[document.frmFilter.Tipo.selectedIndex].value;
if (sel == "empresa"){
document.frmFilter.cmb.length = empresas.length;
document.frmFilter.txt.value = empresas.length;
for (i=0;i<empresas.length;i++){
document.frmFilter.cmb.options[i].value = empresas[i];
document.frmFilter.cmb.options[i].text = empresas[i];
}
}
...
...
}
Well, the problem is that "empresas" and "categorias", not is retrieved successfully. What can i do? What is the problem in the call function(template)?
Thanks and sorry for my english poor.
