Jump to content

Do you think this would work? [Question]


Recommended Posts

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;}}

  • Like 1
Link to post
Share on other sites

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

Edited by Mudsaf
Link to post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...