Newbie: checkbox problem?

M

morellik

Dear all,

I've a problem using JS and Ajax on IE using prototype (under FireFox
all works fine). I've a lot of checkbox:
<input type="checkbox" id="0" name="iu" onClick="loadUsers(this.id);">
<input type="checkbox" id="0" name="iu" onClick="loadUsers(this.id);">
<input type="checkbox" id="0" name="iu" onClick="loadUsers(this.id);">

When I select one checkbox, the loadUsers function have to uncheck
eventually other checkbox active, write it id into the page, display
some select list (with id='enters'), call an Ajax function that fill
the first select list.

So on IE all works fine only if I select the first checkbox of the
list. If I select the other checkbox, appears only the select list and
nothing happen, no unchecking of other checkbox, no writing id in the
page, no filling the first select list.

Where is the problem?
Thanks
Enrico

Follow the block of select list and the js functions.

<div id="enters" style="display:none">
<select id="users" onChange="loadData();" ></select>
<select id="projects" ></select>
<select id="symbols" ></select>
<select id="number" onChange="writeData();"></select>
</div>


var askUsers=false;
var users;
var checkbox_id;
function sendData() {
var myAjax = new Ajax.Request (
'askUsers',
{
asynchronous : false,
method : 'get',
onSuccess : function(transport) {
users=transport.responseText;
},
onFailure : function() { alert('Something went
wrong...') }
}
);

}

function loadUsers(id) {
if ($(id).checked) {

$('projects').options.length = 0;
$('number').options.length = 0;
checkbox_id=id;
$('message').innerHTML=id;
var form=$('signup');
var i=form.getElements('checkbox');
i.each(function(item) {
if (id!=item.id && item.checked) item.checked=false
});

$('enters').show();

if (! askUsers) {
sendData();
askUsers=true;
}
var u=users.split(',');
//alert(u);
$('users').disabled=false;
$('users').options[0] = new Option('Select an user','0');
for (var i=0;i<u.length;i++) {
$('users').options[i+1] = new Option(u, u);
}
$('symbols').options[0] = new Option('Select a symbol','0');
var i=0
for (s in symbols) {
i=i+1;
$('symbols').options = new Option(s, symbols);
}
}
else {
$('enters').toggle();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,664
Latest member
Phil79581

Latest Threads

Top