hi all, ive just found this script and it works well! However i dont want the link function there so can someone please delete what needs deleting so it still works cause when i delete the link parts it stops working...
I only want to click a button and an image swops which is what it does. But this code also includes a onclick of the image it opens a URL and i need that part deleting from all images.. Its embeded in the Jscript..
any help will be greatly appreciated!
Cheers then
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<head xmlns="http://www.w3.org/1999/xhtml">
<title>Js Testing</title>
<style type="text/css">
button {
border: solid 1px #000000;
text-decoration:none;
color:#000000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
font-weight: normal;
font-variant: normal;
padding:4px;
background-color:#99FF66;
float:left;
margin-left:5px;
margin-top:10px;
}
button:hover {
border: solid 1px #333333;
text-decoration:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
font-weight: normal;
font-variant: normal;
padding:4px;
background-color:#00CC33;
float:left;
margin-left:5px;
margin-top:10px;
}
</style>
</head>
<body>
<div id="header">
<h1>Javascript Testing</h1>
</div>
<script type="text/javascript">17.18
/*Image data: src, link */
var data = [
{src: "images/random2.jpg", link: "http://google.com"},
{src: "images/random3.jpg", link: "http://yahoo.com"},
{src: "images/random4.jpg", link: "http://chapo.co.cc"}
];
/* This function will be called when button is clicked.*/
function buttonClick(index) {
if(!data[index]) {
alert("No data found at index : " + index);
return;
}
var src = data[index].src; var link = data[index].link;
var img = document.images.im1;
/* Changing image attributes */
img.src = src; img.onclick = function() { window.open(link);
};}
</script>
<div>
<img src="images/random1.jpg" name="im1" onclick="window.open('http://google.com')"/><br/>
<button onclick="buttonClick(0);">1</button>
<button onclick="buttonClick(1);">2</button>
<button onclick="buttonClick(2);">3</button>
</div>
</body>
</html>