[jQuery] Get vars from one event function to another
I am confused about how to do this the right way.
I have a change event which grabs the value of the selected option
list and sets that as a var. But, I would like to add that to the end
of my post string when I submit the form, how would I do this?
$('select').change(function() {
$('select option:selected').each(function() {
var my_val = $(this).val();
});//end each
});//end change
$('#my_submit').submit(function() {
var action = $('form').attr('action');
// How do I get my_val variable into here??
$('form').attr('action', action + 'new_parm=' + my_val);
});