Click here to Skip to main content
15,893,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<html>
<head>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <script src="JScript.js" type="text/javascript"
<pre lang="cs">roller= new Array();
                links=new Array();
                roller[0]= new Image(322,322)
                roller[0].src = 'image/1.jpeg'
                roller[1]= new Image(322,322)
                roller[1].src = 'image/2.jpg'
                roller[2] = new Image(322, 322)
                roller[2].src = 'image/3.jpg'
                //roller[3] = new Image(322, 322)
                //roller[3].src = 'image/6.jpg'
                //roller[4] = new Image(322, 322)
                //roller[4].src = 'image/7.jpg'
                //roller[5] = new Image(322, 322)
                //roller[5].src='image/8.jpg'

                showthis = 0;

                    function RandomSwapOut(t) {
                    showthis = parseInt((Math.random() * (roller.length - 1)) + 1);
                    alert(t);
                    alert(showthis+1);
                    var img = document.getElementById('digit');
                    img.src = roller[showthis].src;
                    img.parentNode.href = links[showthis];
                    return true;
                }

                function RandomSwapout2() {
                    showthis = parseInt((Math.random() * (roller.length - 1)) + 1);
                    var img = document.getElementById('less');
                    alert(showthis + 1);
                    img.src = roller[showthis].src;
                    img.parentNode.href = links[showthis];
                    return true;
                }


                function RandomSwapout3() {
                    showthis = parseInt((Math.random() * (roller.length - 1)) + 1);
                    var img = document.getElementById('means');
                    alert(showthis + 1);
                    img.src = stoller[showthis].src;
                    img.parentNode.href = links[showthis];
                    return true;
                }


&gt;&lt
;/script&gt;
    &lt;title&gt;Random Image&lt;/title&gt;
    &lt;/head&gt;
   &lt;body&gt;
  &lt;div&gt;
&lt;div id=&quot;Top&quot;&gt;
&lt;h1&gt;Leaders&lt;/h1&gt;

&lt;img id=&quot;digit&quot; src=&quot;image/1.jpeg&quot; onmouseover=&quot;RandomSwapOut(this.src)&quot; onmouseout= &quot;this.&#39;image/2.jpg&#39;&quot; border=&quot;0&quot; height=&quot;322&quot;  width=&quot;322&quot;/&gt;
&lt;img id=&quot;less&quot; src=&quot;image/2.jpg&quot;   onmouseover=&quot;RandomSwapout2(this.src)&quot; onmouseout= &quot;this.&#39;image/3.jpg&#39;&quot; border=&quot;0&quot; height=&quot;322&quot; width=&quot;322&quot; /&gt;
&lt;img id=&quot;means&quot; src=&quot;image/3.jpg&quot;  onmouseover=&quot;RandomSwapout3(this.src)&quot; onmouseout= &quot;this.&#39;image/1.jpeg&#39;&quot; border=&quot;0&quot; height=&quot;322&quot;width=&quot;322&quot; /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
Posted
Comments
Member 9438848 29-Nov-12 1:41am    
instead of using 3 different methods ,, to sum up in one for efficient code!!!
Member 9438848 29-Nov-12 1:46am    
Kindly help as i am a beginner in javascript coding

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900