I don't know what the end goal is, but I often use the following method when I need one to interact with another ...
<a href='whatever.html' rel='#targetElem' class='loadable'> <script> $(document).ready(function(){ $('.loadable').live('click',function(){ </script>
I will tell the element what the purpose of the action is to use the rel attribute ...
to get the variables, try this (the window is a built-in array of global javascript variables ...)
var i=2; var test='i'; document.write('got ' + window[test]);
Fatherstorm
source share