JQ Newb - Using Variables?

JQ Newb - Using Variables?

Hi there

I am trying to create a single function to get the value of various fields.
How do I substitute a variable into the following....

value = $("#myvariable").val();

Obviously the above is incorrect (undefined) as it takes "myvariable" as the literal name of the field.

perhaps...
value = $("#"+myvariable).val();

....is that correct?

Thanks for the help
- JQ Newb :)