I'm having a bit of trouble, I created a simple webpage to download catalogs, and I use javascript to simplify it, with a select the user chooses the catalog they want and the javascript function updates the links in the images so the user can download different formats the thing is, it works ok in firefox and chrome but iexplore just says "actLink is not defined" (translated from spanish actLink no esta definido) and actLink its the function called when the combo box changes, this is what I have:
code that calls the function:
<td align="center"><form id="form1" name="form1" method="post" action="">
<select name="cata_sel" id="cata_sel" onchange="actLink()">
<option value="0" selected="selected">Seleccione el Catálogo...</option>
<option value="Dependencia">Dependencias</option>
<option value="Doc_of">Documentos Oficiales</option>
<option value="EntidadFed">Entidades Federativas</option>
<option value="Estado_Civil">Estado Civil</option>
<option value="Grado_Escolar">Grado Escolar</option>
<option value="Grado_Estudio">Grado de Estudio</option>
<option value="LocYCP">Localidades y Codigos Postales</option>
<option value="Municipio">Municipios</option>
<option value="Nacionalidades">Nacionalidades</option>
<option value="parentesco">Parentescos</option>
<option value="Programas">Programas de Gobierno</option>
<option value="Regiones">Regiones</option>
</select></label>
</form></td>
the script defined in the head secion of the html
<script src="fnc1_0.js">
//<!--
window.onload = function(){//Ocultar todo el contenido
show_hide('descargas',0);
}
function actLink()
{
if($('cata_sel').value!=0)
{
show_hide('descargas',0);
$('dl_pdf').href="cat_dl/Cat_"+$('cata_sel').value+".pdf"
$('dl_csv').href="cat_dl/Cat_"+$('cata_sel').value+".csv"
$('dl_txt').href="cat_dl/Cat_"+$('cata_sel').value+".txt"
$('dl_xls').href="cat_dl/Cat_"+$('cata_sel').value+".xls"
$('dl_pdft').href="cat_dl/Cat_"+$('cata_sel').value+".pdf"
$('dl_csvt').href="cat_dl/Cat_"+$('cata_sel').value+".csv"
$('dl_txtt').href="cat_dl/Cat_"+$('cata_sel').value+".txt"
$('dl_xlst').href="cat_dl/Cat_"+$('cata_sel').value+".xls"
show_hide('descargas',1);
}
else
show_hide('descargas',0);
}
//-->
</script>
the 'dl_' elements are the links to the catalogs. look like this:*
<td><a id="dl_pdf" href="cat_dl/Cat_Dependencia.pdf" target="_blank"><img src="images/pdf-icon_resize.png" width="128" height="128" /></a></td>
the fnc1_0.js has a function to show/hide elements and a '$' named to substitute the getElementById() notation here it is if you need it:
function show_hide(id,act)
{//muestra u oculta divs, act=0:oculta,1:muestra,2:intermitente
//alert(id);
switch(act)
{
case 0:
$(id).style.display ='none'
break
case 1:
$(id).style.display ='block'
break
case 2:
$(id).style.display = ($(id).style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
break
}
}
function $(variable)//reemplaza al getElementbyid
{
return document.getElementById(variable);
}
thats pretty much it, dont know whats wrong ie explore keeps saying that actLink its not defined whenever i select a catalog from the list!! please...hope you can help me!!!!!
1 Answer 1
I think you problem is that you have code in a script tag that has a source, put your code in a script tag without the src attribute.
<script src="fnc1_0.js"></script>
<script>
//<!--
window.onload = function(){//Ocultar todo el contenido
show_hide('descargas',0);
}
function actLink()
{
if($('cata_sel').value!=0)
{
show_hide('descargas',0);
$('dl_pdf').href="cat_dl/Cat_"+$('cata_sel').value+".pdf"
$('dl_csv').href="cat_dl/Cat_"+$('cata_sel').value+".csv"
$('dl_txt').href="cat_dl/Cat_"+$('cata_sel').value+".txt"
$('dl_xls').href="cat_dl/Cat_"+$('cata_sel').value+".xls"
$('dl_pdft').href="cat_dl/Cat_"+$('cata_sel').value+".pdf"
$('dl_csvt').href="cat_dl/Cat_"+$('cata_sel').value+".csv"
$('dl_txtt').href="cat_dl/Cat_"+$('cata_sel').value+".txt"
$('dl_xlst').href="cat_dl/Cat_"+$('cata_sel').value+".xls"
show_hide('descargas',1);
}
else
show_hide('descargas',0);
}
//-->
</script>
1 Comment
Explore related questions
See similar questions with these tags.