+2  A: 

Try this:

for(var key in my_variables)
  query += '&'+key+'='+encodeURIComponent(my_variables[key]);
Carter Galle
WOW! you must have an easy button or something! Thanks Carter. that worked Perfectly as far as I can tell.
pedalpete
+1  A: 

for (var varName in my_variables) { query=query+'&'+varName+'='+my_variables[varName]; }

for (... in ...) is how you write this kind of loop in Javascript. Also use square brackets instead of a period when the field name is a value instead of the actual identifier, like here. Incidentally, I'd also suggest using window.encodeURIComponent if your values might contain arbitrary text.

Dan