Javascript ?

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/68993?pagenum=1
05 November 2025, 00:07

Topic


JJenson
Javascript ?
21 October 2009, 21:54


Alright I am trying to swap an image out and for the life of me I think this should work but it doesn't and I cannto figure out why can anyone else spot it?
Code:

<script language="javascript" type="text/javascript">

function gup(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) return ""; else return results[1]; }


function setimg() {

adclicked = gup('ad');
if (adclicked == 'Oil')
document.getElementById('CouponPicture').src = 'images/OilAd.png';
if (adclicked == 'Radiator')
document.getElementById('CouponPicture').src = 'images/Radiator.gif';
if (adclicked == 'Windshield')
document.getElementById('CouponPicture').src = 'images/Windshield.gif';
if (adclicked == 'Headlights')
document.getElementById('CouponPicture').src = 'images/Headlights.gif';
}

</script>

This is the image in the page its supposed to be updating:

<img src="images/OilAd.png" id="CouponPicture" alt="Click to Print Special!" /></a>

Thanks for the help.
Jeff

 

Replies ...


JJenson
21 October 2009, 22:56


Dumb me nevermind forgot to add onload to the body tag. I need sleep.
© 2000-2021 Snitz™ Communications