If both events are bound to the same object, you can use the .data method:
var obj = $('#element') .data('info',val) .bind('click',do_something) .bind('blur',something_else); function do_something(e) { var el = $(this); var info = el.data('info'); ... el.data('results',val2); } function something_else(e) { var el = $(this); var info = el.data('info'); var results = el.data('results'); ... } -----Original Message----- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Nic Hubbard Sent: Wednesday, August 12, 2009 5:05 PM To: jQuery (English) Subject: [jQuery] Re: Get vars from one event function to another Thanks James for that tip. Still looking for how to pass a var from one event function to another... On Aug 12, 4:28 pm, James <james.gp....@gmail.com> wrote: > I'm not sure I understand what you're trying to do with the change() > function... > You know you can get the value of a select just with val(). You don't > have to loop through each option to find which is selected. > > <select id="mySelect"> > <option value="1">1</option> > <option value="2">2</option> > </select> > > var myVal = $("#mySelect").val(); // 1 or 2 > > On Aug 12, 1:18 pm, Nic Hubbard <nnhubb...@gmail.com> wrote: > > > 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); > > > });