Hola que tal, hora acabo de implementar otro script en una pagina que tengo y funcionaba bien pero a la hora de poner el otro script que tiene un
windows.onload dejo de funcionar la
function countCheckboxes
Alguien sabe como solucionar esto
Código HTML:
Ver original<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript"> function countCheckboxes()
{
var form = document.getElementById('album');
var count = 0;
for(var n = 0; n < form.length; n++)
{
if(form[n].name == 'addAlbum[]' && form[n].checked)
{
count++;
}
}
document.getElementById('checkCount').innerHTML = count;
}
<script type="text/javascript"> //This Function Creates your Cookie for you just pass in the Cookie Name, Value, and number of days before you want it to expire.
function CreateCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime();
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
//This Function reads the value of a given cookie for you. Just pass in the cookie name and it will return the value.
function ReadCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0)
{
return c.substring(nameEQ.length,c.length);
}
}
return null;
}
//This Function Erases Cookies. Just pass in the name of the cookies you want erased.
function EraseCookie(name)
{
CreateCookie(name,"",-1);
}
//Sets or UnSets Cookies for given checkbox after it's been clicked on/off.
function ChangeBox(CheckBox)
{
if (document.getElementById(CheckBox).checked)
{
var CurrentCookie = ReadCookie("checkimg");
CurrentCookie = CurrentCookie + CheckBox;
CreateCookie("checkimg",CurrentCookie,"100");
}
else
{
var CurrentCookie = ReadCookie("checkimg");
CurrentCookie = CurrentCookie.replace(CheckBox,"");
CreateCookie("checkimg",CurrentCookie,"100");
}
}
//Runs on body load to check history of checkboxes on the page.
function CheckCookies()
{
var CurrentCookie = ReadCookie("checkimg");
for (i=0; i<document.CheckList.elements.length; i++)
{
if (document.CheckList.elements[i].type == "checkbox")
{
document.CheckList.elements[i].onclick = function() {ChangeBox(this.id);};
if (CurrentCookie && CurrentCookie.indexOf(document.CheckList.elements[i].id) > -1)
{
document.CheckList.elements[i].checked = true;
}
}
}
}
//Clears Form
function ClearBoxes()
{
for (i=0; i<document.CheckList.elements.length; i++)
{
if (document.CheckList.elements[i].type == "checkbox")
{
document.CheckList.elements[i].checked = false;
ChangeBox(document.CheckList.elements[i].id);
}
}
}
window.onload = CheckCookies;
Saludos y gracias de antemano