[jQuery] Re: Get vars from one event function to another

2009-08-12 Thread Jeffrey Kretz
groups.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, Ja

[jQuery] Re: Get vars from one event function to another

2009-08-12 Thread James
You'd have to set a variable with a scope that both functions can access. For your case, you probably just set a global variable. 'var' sets a variable. var my_val = ''; $('select').change(function() { $('select option:selected').each(function() { my_val = $(this).val()

[jQuery] Re: Get vars from one event function to another

2009-08-12 Thread Nic Hubbard
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 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 > ha

[jQuery] Re: Get vars from one event function to another

2009-08-12 Thread James
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. 1 2 var myVal = $("#mySelect").val(); // 1 or 2 On Aug 12, 1:18 pm, Nic Hu