Using images for checkboxes
Posted: Sat Apr 17, 2004 8:12 pm
I'm looking for something easy to use to allow my application to use images as checkboxes (on.gif and off.gif) instead of normal checkboxes.
Thanks guys.
Thanks guys.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
function check(name)
{
var v = document.formsї<?= $formName ?>]їname]value = parseInt(document.formsї$formName]їname]value) ^ 1;
document.imagesїname].src = (v?('on'):('off'))+'.gif';
}
-----------
<input type=hidden name="<?= $name ?>" value="0"><a onclick="check(this.name)" name="<?= $name ?>"><img src="off.gif" name="<?= $name ?>" /></a>Code: Select all
function getElem(id)
{
return ((document.getElementById)?(document.getElementById(id)):(document.allїid]));
}
function check(id)
{
var o = getElem(id);
var i = getElem(id+'_i');
if(!o || !i) return false;
var v = o.value = (parseInt(o.value)?(0):(1));
i.src = (v?('on'):('off'))+'.gif';
}
-----------
<input type=hidden id="<?= $id ?>" name="threadї]" value="0"><a onclick="check('<?= $id ?>_i')"><img src="off.gif" id="<?= $id ?>_i" /></a>