Passing variables to a function using a button and submittin

I am attempting to setup a multiple select box page that has 1 master select box and a dynamic number of child ones.For example: I have 10 territories and within those 10 territories can be 100 counties. I am using jquery to with buttons “Add” and “Remove” to move these counties between the different selector boxes.Now the challange is to …

via PHP Website Development » Search Results » ajax:

Passing variables to a function using a button and submittin

I am attempting to setup a multiple select box page that has 1 master select box and a dynamic number of child ones.
For example: I have 10 territories and within those 10 territories can be 100 counties. I am using jquery to with buttons “Add” and “Remove” to move these counties between the different selector boxes.
Now the challange is to create javascript to submit the changes via ajax. I know I am doing this the hard way right now by making the javascript dynamic with PHP so I am wondering a more simple way, as well as how I can pass those variables into the data string.
Right now I am using this:
The page looks like this:

foreach ($territories as $territory)
echo “

$territory->name

foreach ($counties as $county)
if (is_null($county->territory))
echo “