How can I capture JavaScript value for use on tpl.php I have a custom module, in a javascript file that is located in the js folder of the module, I captured a value from a previously written function using an if statement. Ex: if($numb==6) show this img else show this img.  

I need to access this value/var so I can display a particular image on my tpl.php when it loads.

How can I accomplish this in drupal7?
What you can do in this particular case is add the HTML for both the images inside tpl file.
On the js file, you can display/hide the images according to your IF condition.

To capture JS value for use in tpl, you can use javascript/ajax to send the information through a url / xmlhttp and then use hook menu to grab the information inside module file, then send the variable to the tpl