vendredi 27 février 2015

javascript display multiple images

Just to let you know I am a complete newbie, I have a html page that shows different images combined. I am using javascript to select images to display. Here's my code:



<head>
<script type="text/javascript">
var num1 = Math.ceil( Math.random() * 6 );
var num2 = Math.ceil( Math.random() * 6 );
var num3 = Math.ceil( Math.random() * 6 );
var num4 = Math.ceil( Math.random() * 6 );
var num5 = Math.ceil( Math.random() * 4 );
var imgpath1 = "<img src=" + '"' ;
var imgpath2= "./Nums24-38/Nums" + num5 + "_";
var imgpath3= ".png" + '"' ;
var imgpathA = imgpath1 + imgpath2 + num1 + imgpath3 ;
var imgpathB = imgpath1 + imgpath2 + num2 + imgpath3 ;
var imgpathC = imgpath1 + imgpath2 + num3 + imgpath3 ;
var imgpathD = imgpath1 + imgpath2 + num4 + imgpath3 ;
var imgpathE = imgpathA + imgpathB + imgpathC + imgpathD ;
</script>
</head>
<body>

<h1>Hello </h1>
<h2>Welcome to Home-brewed Captcha </h2>

My Random number is <script>document.write(num1); document.write(num2); document.write(num3);document.write(num4)</script>

<p> My path is <script>document.write(imgpath2); document.write(num1); document.write(imgpath3) </script></p>

<p>First Java Image is <script>document.write(imgpathA) </script> </p>

<p>Second Java Image is <script>document.write(imgpathB) </script> </p>

<p>Third Java Image is <script>document.write(imgpathC) </script> </p>

<p>Fourth Java Image is <script>document.write(imgpathD) </script> </p>


<p> Merged Java Image ABCD is
<script> document.write(imgpathA) </script>
<script> document.write(imgpathB) </script>
<script> document.write(imgpathC) </script>
<script> document.write(imgpathD) </script>
</p>


<p> New merged Java image A+B+C+D is<script>document.write(imgpathE) </script> </p>

<h3>Another merge , this time bypassing java <img src="./Nums24-38/Nums3_3.png"><img src="./Nums24-38/Nums3_1.png"><img src="./Nums24-38/Nums3_0.png"><img src="./Nums24-38/Nums3_6.png"></h3>
</body>


You can see a live demo at http://ift.tt/1Bosdo7 Why does all images dont show up. Where am I going wrong. Muja


Aucun commentaire:

Enregistrer un commentaire