par
Vurtu » 24 août 2008, 01:05
Pour information, voici le code :
Code : Tout sélectionner
var personnalSelectOpenned = false;
function replaceSelect()
{
var selectNum = 0;
document.getElements('select').each(function(item, index)
{
parentNode = item.getParent();
// hidden input for sending
hidden = new Element('input', {
'type': 'hidden',
'name': item.name,
'id': 'personnalSelectValue' + selectNum,
'value': item.value
});
// list with dl, dt, dd, ul, li
dl = new Element('dl', {
'class': 'select'
});
dt = new Element('dt', {
'id': 'personnalSelectTitle'+ selectNum,
'onclick': 'personnalSelectShow('+ selectNum +'); return false;'
});
dt.appendText(item.options[item.selectedIndex].text + " ");
dd = new Element('dd', {
'id': 'personnalSelect' + selectNum
});
ul = new Element('ul');
item.getElements('option').each(function(option, index)
{
li = new Element('li', {
'onclick': 'personnalSelectSetValue(this, '+ selectNum +', "'+ option.value +'");'
});
li.appendText(option.text + ' ');
ul.grab(li);
});
dd.grab(ul);
dl.grab(dt);
dl.grab(dd);
item.destroy();
parentNode.grab(hidden);
parentNode.grab(dl);
++ selectNum;
});
}
function personnalSelectShow(id)
{
if ( personnalSelectOpenned )
personnalSelectShow(personnalSelectOpenned);
id = 'personnalSelect' + id;
if ( $(id).getStyle('display') == 'none' )
{
$(id).setStyle('display', 'block');
personnalSelectOpenned = id;
}
else
{
$(id).setStyle('display', 'none');
personnalSelectOpenned = false;
}
}
function personnalSelectSetValue(li, id, value)
{
$('personnalSelectTitle'+ id).innerHTML = li.innerHTML;
$('personnalSelectValue'+ id).value = value;
personnalSelectShow(id);
}
window.addEvent('domready', function() {
replaceSelect();
});
Ca se passe à la création du dt ...
Code : Tout sélectionner
'onclick': 'personnalSelectShow('+ selectNum +'); return false;'
J'ai essayé différente méthodes, rien n'y fait ...
Je voulais essayer ta méthode, mais je n'ai pas compris comment passer les arguments à ma fonction ...
Pour information, voici le code :
[code]var personnalSelectOpenned = false;
function replaceSelect()
{
var selectNum = 0;
document.getElements('select').each(function(item, index)
{
parentNode = item.getParent();
// hidden input for sending
hidden = new Element('input', {
'type': 'hidden',
'name': item.name,
'id': 'personnalSelectValue' + selectNum,
'value': item.value
});
// list with dl, dt, dd, ul, li
dl = new Element('dl', {
'class': 'select'
});
dt = new Element('dt', {
'id': 'personnalSelectTitle'+ selectNum,
'onclick': 'personnalSelectShow('+ selectNum +'); return false;'
});
dt.appendText(item.options[item.selectedIndex].text + " ");
dd = new Element('dd', {
'id': 'personnalSelect' + selectNum
});
ul = new Element('ul');
item.getElements('option').each(function(option, index)
{
li = new Element('li', {
'onclick': 'personnalSelectSetValue(this, '+ selectNum +', "'+ option.value +'");'
});
li.appendText(option.text + ' ');
ul.grab(li);
});
dd.grab(ul);
dl.grab(dt);
dl.grab(dd);
item.destroy();
parentNode.grab(hidden);
parentNode.grab(dl);
++ selectNum;
});
}
function personnalSelectShow(id)
{
if ( personnalSelectOpenned )
personnalSelectShow(personnalSelectOpenned);
id = 'personnalSelect' + id;
if ( $(id).getStyle('display') == 'none' )
{
$(id).setStyle('display', 'block');
personnalSelectOpenned = id;
}
else
{
$(id).setStyle('display', 'none');
personnalSelectOpenned = false;
}
}
function personnalSelectSetValue(li, id, value)
{
$('personnalSelectTitle'+ id).innerHTML = li.innerHTML;
$('personnalSelectValue'+ id).value = value;
personnalSelectShow(id);
}
window.addEvent('domready', function() {
replaceSelect();
});
[/code]
Ca se passe à la création du dt ...
[code]'onclick': 'personnalSelectShow('+ selectNum +'); return false;'[/code]
J'ai essayé différente méthodes, rien n'y fait ...
Je voulais essayer ta méthode, mais je n'ai pas compris comment passer les arguments à ma fonction ...