I have a problem I can not solve, I have a form which contains a section inputs checkbox that are generated dynamically, the name of this input keep it as mail_2 [] my problem is how can Pick up that array in js to send it to php where the array will be treated?
My question would be then, how to send the fix from js to php? I intend it in the following way, but when I see it, it seems that nothing is sent:
mail_2 = document.mailing.elements['mail_2[]'];
My input:
<div class="form-group">
<label>Promociones Disponibles:</label>
<div class="checkbox checkbox-primary">
<?php
while($f=mysql_fetch_array($re)) { ?>
<input name="mail_2[]" id="mail_2" class="styled" type="checkbox" value="<?php echo $f[llave] ?>">
<label>
<?php echo $f[titulo] ?>
</label>
<br>
<?php }
?>
</div>
</div>
This is my complete function:
function mailing_envio(){
var selectedValues = [];
$("#ms :selected").each(function(){
selectedValues.push($(this).val());
});
//alert(selectedValues);
//return false;
titulo_mail = document.mailing.titulo_mail.value;
mail_2 = document.mailing.elements['mail_2[]'];
ajax = objetoAjax();
if(selectedValues=='usuarios'){
//alert("correo para usuarios");
ajax.open("POST", "class/mailing_enviar.php", true);
}else if(selectedValues=='prospectos'){
alert("correo para prospectos"+mail_2);
//ajax.open("POST", "class/actualizar.php", true);
}else{
alert("correo para todos");
}
ajax.onreadystatechange=function() {
if (ajax.readyState==2) {
alert("Datos enviados)
}
}
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.send("titulo_mail="+titulo_mail+"&mail_2="+mail_2)
}