Forum Moderators: open

Message Too Old, No Replies

Sending Specific Array Value with Prototype.js

         

JohnPorier

3:42 pm on Sep 26, 2007 (gmt 0)

10+ Year Member



I have a previous thread with a similar issue, however I think the amount of code I entered is shying people away from it.

I am trying to take a different approach by using Prototype.js
This framework looks great, I'm just not sure how to do a particular thing. How do I send specific array values via the Prototype.js ajax framework to another PHP file to process the data?

For instance, say I list some users with a PHP array in a table. When the user is clicked on, I want the array value (users name) of that specific user sent, I need to do it with an array. Anyone know the code to get this done?

Thank in advance!

[edited by: JohnPorier at 3:44 pm (utc) on Sep. 26, 2007]

misterjonez

4:11 am on Sep 27, 2007 (gmt 0)

10+ Year Member



Hi here's my idea.

I hope this could help u.

Javascript

<script>
var x=new Array();
var i;
x[0]="1";
x[1]="2";
i=x.join(","); //result i: 1,2
new Ajax.Request('jsarray.php', { parameters: {a:i}});
</script>

jsarray.php

<?php
$a=$_POST['a'];
$myphparray=explode(",",$a);
print_r($myphparray); //result $myphparray: array ( [0]=>1 [1]=>2 )
?>