Hi,
See the basic approach is submit the form and then collect it in ur server variable using request object. if u r submitting to different form then its easy enough !!! if its on same page then its also easy though lil tricky, for that u'll have to check the value of collected var if it has some value means time to execute the query.
and yes the client side var u'll have to assign to any form field(mostly ppl use hidden ones) b4 submitting.
I hope It'll help
Best Luck..
Nilesh