Mudsaf Posted February 1, 2012 Share Posted February 1, 2012 So the basic idea, in the webpage there would be example <span id="Images"></span> and the images should go inside. For example if the count = 0 the image 0.jpg would go inside span. Example2 if the count =1 image 1.jpg would go inside span. Im just asking does this look like it would work? Haven't tested yet. // JavaScript Documentvar count = 0;function image() {var img = document.getlementById("Images").innerHTML='<img src="/includes/images/' && count && '.jpg " width="800" height="600" />';}function nextimage() {count = count + 1;}function previousimage() {if (count = 0) {alert("You are already in beginning of images, you can't go back");} else {count = count -1;}} Link to comment Share on other sites More sharing options...
eTianbun Posted February 1, 2012 Share Posted February 1, 2012 Why not test it, and see? Link to comment Share on other sites More sharing options...
Mudsaf Posted February 1, 2012 Author Share Posted February 1, 2012 Alrights, ill give try tried to save time. Link to comment Share on other sites More sharing options...
Mudsaf Posted February 1, 2012 Author Share Posted February 1, 2012 somehow i can't get even this working O.o <html><head> <script type="text/javascript">document.getElementById("peanut").innerHTML="ABC";</script></head><body> <span id="peanut"></span> </body></html> Fixed, required button to call function Link to comment Share on other sites More sharing options...
eTianbun Posted February 1, 2012 Share Posted February 1, 2012 That's because the <script> was executed, before the <span> was created. Try the other way round (put the <script> tag below the <span> tag in the <body> tag). Link to comment Share on other sites More sharing options...
Mudsaf Posted February 1, 2012 Author Share Posted February 1, 2012 This progress working so far! <html><head><script type="text/javascript">count = 0;var url = "<img src='includes/images/";var imageending = ".jpg'";var stats = " width='800' height='600' />";var everything = (url + count + imageending + stats);function start() {document.getElementById("images").innerHTML=(everything);} function nextimage() {count = count + 1;var url = "<img src='includes/images/";var imageending = ".jpg'";var stats = " width='800' height='600' />";var everything = (url + count + imageending + stats);document.getElementById("images").innerHTML=(everything);// "<img src='includes/images/'" && count && '.jpg' && "width='800' height='600' />"; } </script></head><body onLoad="start();"><span id="images"></span><input name="button" value="Previous" type="button" onclick="previousimage();"><input name="button" value="Next" type="button" onclick="nextimage();"></body></html> Link to comment Share on other sites More sharing options...
Mudsaf Posted February 1, 2012 Author Share Posted February 1, 2012 Thanks all for helping me with this problem. Feel free to use this code anywhere, not even single line leeched anywhere & feel free to edit if needed! <html><head><script type="text/javascript">count = 0;var url = "<img src='includes/images/";var imageending = ".jpg'";var stats = " width='800' height='600' />";var everything = (url + count + imageending + stats);function start() {document.getElementById("images").innerHTML=(everything);} function nextimage() {count = count + 1;var url = "<img src='includes/images/";var imageending = ".jpg'";var stats = " width='800' height='600' />";var everything = (url + count + imageending + stats);document.getElementById("images").innerHTML=(everything);}function previousimage() {if (count == 0) {alert("You already on startpage");} else {count = count - 1;var url = "<img src='includes/images/";var imageending = ".jpg'";var stats = " width='800' height='600' />";var everything = (url + count + imageending + stats);document.getElementById("images").innerHTML=(everything);}}</script></head><body onLoad="start();"><span id="images"></span><input name="button" value="Previous" type="button" onclick="previousimage();"><input name="button" value="Next" type="button" onclick="nextimage();"></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.