Hi Everyone,
Just having a few problems getting a script to work.
What I need to do is take the values from a series of checked checkboxes and write them to an array.
Once this is done I need to convert the array to a CSV string (using array.join) and use this string to populate a hidden field.
The problem i'm having is when I try to take the value assigned to " i " and use it in the if statement below. Does anyone know a work around for this?
NB. Checkbox names are sequential. Script is called onClick of submit button
Many thanks!!!
Just having a few problems getting a script to work.
What I need to do is take the values from a series of checked checkboxes and write them to an array.
Once this is done I need to convert the array to a CSV string (using array.join) and use this string to populate a hidden field.
The problem i'm having is when I try to take the value assigned to " i " and use it in the if statement below. Does anyone know a work around for this?
NB. Checkbox names are sequential. Script is called onClick of submit button
Code:
<script language="javascript" type="text/javascript">
var recipient = new Array()
function AddRecipients() {
alert("Function has been called");
for (var i = 0; i==recipient.length; i++) {
alert("For statement has worked");
alert(i);
if (document.consultationsForm.recipientdetails_[i].checked == true) {
alert("If statement has worked");
recipient.push(document.consultationsForm.recipientdetails_[i].value);
alert(recipient);
}
}
}
</script>
Code:
<form method="post" name="consultationsForm" action="">
<input type="checkbox" name="recipientdetails_0" value="emailaddress_a@mydomain.com">
<input type="checkbox" name="recipientdetails_1" value="postaddress_@mydomain.com">
Many thanks!!!