Thunderforge
-
Posts
5 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Thunderforge
-
-
Haha! You guys are awesome!! :-D
I haven't exactly done what you each suggested but I've got what I wanted and needed everything you all said!
[@dsonesuk - that is a very eloquent way of condensing it, which I like very much; but in the bigger project this is all going into would probably be too restricting for me.]
Here is my final code;
<html><button onclick="justTextFunc()">COLOUR</button><br><span id="justChoseText"></span><br><img id="justChosePic" src="" alt="Click the button!"><script>var justText = [{text: 'RED', image: 'Red.gif'}, {text: 'GREEN', image: 'Green.gif'}, {text: 'BLUE', image: 'Blue.gif'}, ];function justTextFunc() {var pickText = justText [Math.floor(Math.random()*justText.length)];document.getElementById("justChoseText").innerHTML = pickText.text;document.getElementById("justChosePic").src = pickText.image;}</script></html> -
I didn't know you could combine different types of thing in a variable!
Of course I don't know how to separate the parts again afterwards...
This is my code, presumably I need a function to id the image as well?
<html><button onclick="someFunction()">COLOUR</button><br><text id="chooseColour"></text><img id="chooseColour"></img><script>var colourText = [{text: 'RED', image: 'Images/Red.gif'},{text: 'GREEN', image: 'Images/Green.gif'},{text: 'BLUE', image: 'Images/Blue.gif'},];function someFunction() {var pickColour = colourText [Math.floor(Math.random()*colourText .length)];document.getElementById("chooseColour").innerHTML = pickColour; }</script></html> -
Hi, can anyone help me with this - I keep drawing blanks!
A button which throws up a random word from an array, which is fine, I've got that.
But I want it to also display an image based on that result, i.e.; from var colourPicker('red','blue','green'); then if, for example, text=='red' then the image displayed is Red.gif
I'm sure it's simple to do but I can't get it to work! Any help would very much be appreciated.
Thanks,
Thunderforge
-
Hello! I'm Thunderforge, I don't know much about html, but learning slowly!
Generated SRC Paths?
in General
Posted
I want to randomly generate an src path for an image, for example;
src = <var1>/<var2>.gif
I'm sure it can be done, but not sure at what level it would go in. This is what I have;
var huePick =[{text:'light',image:'light'},{text:'dark',image:'dark'}];