How do I use AjaxRequest to POST checkboxes which is an array, not a
variable?
[code]
=====================================
<script type="text/javascript">
function addEvent(day, month, year, body, involved) {
if(day && month && year && body && involved) {
//alert('Add Event \n Day: '+day+'\n Month:
'+month+'\n Year:
'+year+'\n Involved: '+involved+'\n Body: '+body);
new Ajax.Request('rpc.php', {method: 'post', postBody:
'action=addEvent&d='+day+'&m='+month+'&y='+year+'&involved='+involved
+'&body='+body+'', onSuccess: highlightEvent(day)});
$('evtBody').value = '';
} else {
alert('There was an unexpected script error.\nPlease
ensure that
you have not altered parts of it.');
}
</script>
========================================
[/code]
It posts information using ajax but the rpc.php thinks that $involved
equals 1.
What it doesn't know is that $involved is an array, which when echoed
reads Array because it has $involved[0] and $involved[1]. Below is
rpc.php for a calendar script.
[code]
===========================================
$day = $_POST['d'];
$month = $_POST['m'];
$year = $_POST['y'];
$body = $_POST['body'];
$involved = $_POST["involved"];
$howmany = count($involved);
$timeStamp = mktime(0,0,0, $month, $day, $year);
$bodyF = addslashes(trim($body));
$addEvent = mysql_query("INSERT INTO event (body, timestamp,
userid,
involved) VALUES ('$body', '$timeStamp', '$logged[id]', '$howmany')",
$conn);
$daidting = mysql_insert_id();
$addInvolved = mysql_query("INSERT INTO involved (eventid,
userid)
VALUES ('$daidting', '$howmany')", $conn);
foreach ($involved as $f) {
//echo $f."<br />";
$addInvolved = mysql_query("INSERT INTO involved (eventid,
userid)
VALUES ('$daidting', '$f')", $conn);
}
=======================
[/code]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---