0 Пользователей и 1 Гость просматривают эту тему.
  • 2 Ответов
  • 5067 Просмотров
*

ButuzOFF

  • Захожу иногда
  • 144
  • 22 / 2
Захотелось немножко отойти от стандартного оформления чекбоксов :)
Может кому сгодиться  ^-^
Вставить в index.php шаблона до тега </head>
Код
<script language="javascript" src="<?php echo $mosConfig_live_site;?>/templates/<?php echo $cur_template; ?>/checkbox.js" type="text/javascript"></script>	
В яваскрипте checkbox.js прописать путь к картинкам
А сам скрипт кинуть в папку с шаблоном
Код
var imgFalse = 'false.png';
var imgTrue = 'true.png';
соответственно
Цитировать
var imgFalse = 'http://mysite/images/false.png';
var imgTrue = 'http://mysite/images/true.png';
Скрипт в аттаче
Упс.. Папка вложений заполнена  :(
Тогда дам ссылочку на свой сайт  ;D

Тута
« Последнее редактирование: 04.08.2007, 19:28:51 от ButuzOFF »
*

Sulpher

  • Живу я здесь
  • 2112
  • 401 / 16
  • Шаблоны и расширения Joomla
*

poizon

  • Захожу иногда
  • 495
  • 187 / 1
  • Buu
Содержимое файла checkbox.js
Код
//global variables that can be used by ALL the function son this page.
var inputs;
var imgFalse = 'false.png';
var imgTrue = 'true.png';

//this function runs when the page is loaded, put all your other onload stuff in here too.
function init() {
replaceChecks();
}

function replaceChecks() {

//get all the input fields on the page
inputs = document.getElementsByTagName('input');

//cycle trough the input fields
for(var i=0; i < inputs.length; i++) {

//check if the input is a checkbox
if(inputs[i].getAttribute('type') == 'checkbox') {

//create a new image
var img = document.createElement('img');

//check if the checkbox is checked
if(inputs[i].checked) {
img.src = imgTrue;
} else {
img.src = imgFalse;
}

//set image ID and onclick action
img.id = 'checkImage'+i;
//set image
img.onclick = new Function('checkChange('+i+')');
//place image in front of the checkbox
inputs[i].parentNode.insertBefore(img, inputs[i]);

//hide the checkbox
inputs[i].style.display='none';
}
}
}

//change the checkbox status and the replacement image
function checkChange(i) {

if(inputs[i].checked) {
inputs[i].checked = '';
document.getElementById('checkImage'+i).src=imgFalse;
} else {
inputs[i].checked = 'checked';
document.getElementById('checkImage'+i).src=imgTrue;
}
}

window.onload = init;
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Изменение внешнего вида select, radio и checkbox [how to]

Автор poizon

Ответов: 11
Просмотров: 43528
Последний ответ 31.08.2010, 18:30:58
от Markiz
Оформление стандартных шаблонов представления контента

Автор tee-rax

Ответов: 4
Просмотров: 2383
Последний ответ 08.06.2009, 19:39:12
от tee-rax