Join for FREE | Take the Tour Lost Password?
Shop deviantART for the
holidays and save BIG!
Click here! :holly:
[x]

deviantART

:date:
 




<script type="text/javascript">
// simple image viewer: her.bird@gmail.com

// INSERT YOUR IMAGE URLS HERE

imgList = new Array(
"img1.gif","img2.jpg","img3.bmp"
);

// THE MAIN FUNCTION, NEEDS NO CHANGES

function changeImage(){
imgFetch = document.canvasForm.canvasSelect.value;
if(imgFetch == ""){
false;
}else{
document.write("<div><img border='0' src='"+imgFetch+"' /></div>");
document.write("go back");
}
}

// THIS IS THE SELECT FORM

document.write("<form name='canvasForm'>");
document.write("<select name='canvasSelect' size='1' onchange='changeImage()'>");
document.write("<option value=''>select image...</option>");
for(imgC=0;imgC<imgList.length;imgC++){
document.write("<option value='"+imgList[imgC]+"'>"+imgList[imgC]+"</option>");
}
document.write("</select>");
document.write("</form>");
document.write("<div id='theCanvas'></div>");
</script>

1) First you have an array that keeps all of your image URLs.

2) Then the function that loads up the value from the select box.

3) And writes the <img> tag with the loaded image value (URL).
Creative Commons License
Some rights reserved. This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.
:iconbertman:

Author's Comments

Uses JavaScript. Selected image will be loaded onto a DIV layer.

Comments


love 0 0 joy 0 0 wow 0 0 mad 0 0 sad 0 0 fear 0 0 neutral 0 0
:icondetendez:
Hi.
Fantastic work mate.
Can I ask you a question about scripting?

I'm kind of new and I need to make one of those modules you click and the writing appears and disappears.
The problem is, there isn't a tutorial anywhere on the web and I need it pronto :S
Please could you perhaps make the script for one of these?
thanks

detendez
:iconbertman:
no problem. check out my next tutorial ;)

--
[link]
:icondetendez:
ok
where do i go for that?
:icondetendez:
thanks
if i experience any difficulties...please could i ask?
:icondetendez:
Thanks! And sorry for the long interval before I replied. Holidays.

Details

April 15, 2008
1.5 KB
2.3 KB
150×150

Statistics

8
4 [who?]
420 (1 today)
18 (0 today)

Share

Link
Thumb

Site Map