How to know if i click any link in drupal and set a variable?
As I understand it, you need to pass a value via the URL, and fix a forms element based on this.

You have to output a link ith your variable in it, in the form yoursite.com?variable=value, preferably via the l() function.

On your second page, the value will be accessible in several ways, for example in the $_GET variable.

More powerfull and Drupalish, you could also implement a hook_menu to be able to use clean URLs like yoursite.com/some_menu_entry/yourvalue and the corresponding function.