Javascript: Radio button and displaying images based on a vaule
<p>I am currently working with displaying images based on the value chosen from a radio button. But I am currently running into a wall with making the code as short and efficient as possible. I have several categories to choose from and they way i am approaching the issue will require for me to write several <code>check_value#</code>. Is there a way to combine those two functions? so in the future if i have 5 or 7 categories i wont have to have a function for each. <a href="http://webprolearner2346.zxq.net/bike_calculator/" rel="nofollow">EXAMPLE</a> </p>

<pre><code>&lt;script&gt;
 function check_value(val) {     
    var el = document.getElementById("imgBox1");
    var img = imgs[val];
    if (val&gt;0 &amp;&amp; val&lt;4) { //will trigger when [1,2,3]
        el.src = "images/bike" + val + ".jpg";
        el.style.display = "";
    }    
}

 function check_value1(val) {    
    var el = document.getElementById("imgBox2");
    var img = imgs[val];
    if (val&gt;0 &amp;&amp; val&lt;4) { //will trigger when [1,2,3]
        el.src = "images/tire" + val + ".jpg";
        el.style.display = "";
    }    
}
&lt;/script&gt;    
</code></pre>

<p><strong>HTML</strong></p>

<pre><code>&lt;h2&gt;Choose a bike&lt;/h2&gt;
    &lt;form name="builder"&gt;
        &lt;input type="radio" name="field" value="1" onclick='check_value(0)'/&gt; KAWASAKI KX 450F&lt;br /&gt;
         &lt;input type="radio" name="field" value="2" onclick='check_value(1)'/&gt; 2010 Yamaha Road Star S&lt;br /&gt;
         &lt;input type="radio" name="field" value="3" onclick='check_value(2)'/&gt; Aprilia RSV4&lt;br /&gt;
    &lt;/form&gt;

&lt;img id="imgBox1" src="#" style="display:none"&gt; 

&lt;h2&gt;Choose a tire&lt;/h2&gt;  
    &lt;form name="tire"&gt;
        &lt;input type="radio" name="field" value="1" onclick='check_value1(0)'/&gt; Michelin Pilot Road 3 Tires&lt;br /&gt;
        &lt;input type="radio" name="field" value="2" onclick='check_value1(1)'/&gt; Dunlop Roadsmart Sport-Touring Tires&lt;br /&gt;
         &lt;input type="radio" name="field" value="3" onclick='check_value1(2)'/&gt; Pirelli Scorpion Trail Tires&lt;br /&gt;
    &lt;/form&gt;

&lt;img id="imgBox2" src="#" style="display:none"&gt; 
</code></pre>
