I'm having a scope issue with a javascript function
The variable checkedones
is not passing to the AJAX.Updater.
The item.value is reporting a value so I know that there should be something there, however I'm just left with t pland when I get to the last alert.
How can this be fixed/improved?
function sendem开发者_JS百科ail(){
var checkedones='';
var i= $$('.emailer');
i.each(function(item)
{
if(item.checked){
alert(item.value);
alert(item.checked);
var checkedones = checkedones + item.value + ',';
}
}
)
alert(checkedones);
new Ajax.Updater('asdfa', 'pages/domailing.php', {
method:'post',evalScripts:'true' ,parameters: {
subject1:$('subject1').value,
subject2:$('subject2').value,
body:tinyMCE.get('emailbody').getContent(),
value:checkedones},
evalJS:'force',
onComplete:function(){}
});
}
try changing: var checkedones = checkedones + item.value + ',';
to: checkedones += (item.value + ',');
you've re-declared by using var
inside the loop.
精彩评论