Post by CrAzY_J on Jan 27, 2006 6:41:17 GMT -8
Code description: I got this idea from Peter's PBV3 avatar gallery, so credits to him too. The code displays all the avatars which are in the drop down menu, in the cell where the description normally is. And the user chooses a avatar by clicking a image. (see preview).
Code preview: Click
Main Footers:
<script type='text/javascript'>
/* Avatar Gallery
created by CrAzY_J
do not redistribute this code without the creator's permission*/
if( document.modifyForm )
{
var ASelect = document.modifyForm.avatar;
var ARow = ASelect.parentNode.parentNode.parentNode;
ASelect.style.display = 'none';
ARow.cells[2].removeChild( ARow.cells[2].firstChild );
ARow.cells[2].appendChild(document.createElement('div'));
for( var x = 1 ; x < ASelect.options.length ; x ++ )
{
var CJImage = document.createElement('img');
var CJLink = document.createElement('a');
CJImage.src = ( new RegExp('^http:','i').test(ASelect.options[x].value) )? ASelect.options[x].value : 'http://www.proboards.com/v4images/avatars/'+ASelect.options[x].value+'.gif';
CJImage.border = 0;
CJImage.style.cursor = 'pointer';
CJImage.onclick = function()
{
document.images.avatarImage.src = this.src;
}
ARow.cells[2].firstChild.appendChild( CJImage );
ARow.cells[2].firstChild.appendChild( document.createTextNode(' ') );
}
var HideShow = document.createElement('a');
HideShow.href = 'javascript:void(0);';
HideShow.appendChild( document.createTextNode('hide/show') );
HideShow.onclick = function(){
var Last = document.modifyForm.avatar.parentNode.parentNode.nextSibling
Last.firstChild.style.display = (Last.firstChild.style.display == 'none')? '':'none';
}
ARow.cells[1].insertBefore( HideShow, ARow.cells[1].firstChild )
function changeselect(event)
{
if( document.modifyForm.avatarurl.value == '' )
{
var final = document.images.avatarImage.src;
for( var y = 1 ; y < ASelect.options.length ; y ++ )
{
if( new RegExp(ASelect.options[y].value,'i').test(final) )
{
ASelect.selectedIndex = y;
break;
}
}
}
}
if( document.addEventListener )
document.modifyForm.addEventListener('submit',changeselect,false);
else
document.modifyForm.attachEvent('onsubmit',changeselect);
}
</script>
Enjoy
* 4-13-11, Changed variable name to prevent naming conflicts- Wormo
Code preview: Click
Main Footers:
<script type='text/javascript'>
/* Avatar Gallery
created by CrAzY_J
do not redistribute this code without the creator's permission*/
if( document.modifyForm )
{
var ASelect = document.modifyForm.avatar;
var ARow = ASelect.parentNode.parentNode.parentNode;
ASelect.style.display = 'none';
ARow.cells[2].removeChild( ARow.cells[2].firstChild );
ARow.cells[2].appendChild(document.createElement('div'));
for( var x = 1 ; x < ASelect.options.length ; x ++ )
{
var CJImage = document.createElement('img');
var CJLink = document.createElement('a');
CJImage.src = ( new RegExp('^http:','i').test(ASelect.options[x].value) )? ASelect.options[x].value : 'http://www.proboards.com/v4images/avatars/'+ASelect.options[x].value+'.gif';
CJImage.border = 0;
CJImage.style.cursor = 'pointer';
CJImage.onclick = function()
{
document.images.avatarImage.src = this.src;
}
ARow.cells[2].firstChild.appendChild( CJImage );
ARow.cells[2].firstChild.appendChild( document.createTextNode(' ') );
}
var HideShow = document.createElement('a');
HideShow.href = 'javascript:void(0);';
HideShow.appendChild( document.createTextNode('hide/show') );
HideShow.onclick = function(){
var Last = document.modifyForm.avatar.parentNode.parentNode.nextSibling
Last.firstChild.style.display = (Last.firstChild.style.display == 'none')? '':'none';
}
ARow.cells[1].insertBefore( HideShow, ARow.cells[1].firstChild )
function changeselect(event)
{
if( document.modifyForm.avatarurl.value == '' )
{
var final = document.images.avatarImage.src;
for( var y = 1 ; y < ASelect.options.length ; y ++ )
{
if( new RegExp(ASelect.options[y].value,'i').test(final) )
{
ASelect.selectedIndex = y;
break;
}
}
}
}
if( document.addEventListener )
document.modifyForm.addEventListener('submit',changeselect,false);
else
document.modifyForm.attachEvent('onsubmit',changeselect);
}
</script>
Enjoy
* 4-13-11, Changed variable name to prevent naming conflicts- Wormo