Jump to content

Archived

This topic is now archived and is closed to further replies.

Kris

**SOLVED** Reloading an image

Recommended Posts

I have an image that is generated by PHP based on some form input fields, and to stream-line it I wan't to change the images without reloading the page. So JavaScript is the way! I have written the following script, which does exactly what I want, perfectly in FireFox - But does nothing in IE! Any ideas?
[code]<script language="JavaScript">
function reloadimg() {
    logo = document.getElementById("logo");
    logo = logo.value;
    text = document.getElementById("text");
    text = text.value;
    document.unbrand.src = "preview.php?str="+text+"&btm=s|1";
    document.branded.src = "preview.php?str="+text+"&btm=c|"+logo;
}
</script>[/code]
Now, logo is taken from a <select>, and text is taken from an <input>, both form fields have an onchange="reloadimg()" to trigger the function.

I would say I am a novice at JavaScript, but slowly picking it up here and there. I'm assuming one of the functions I have used in my script is not compatible with IE? Any help is greatly appreciated!

[b]EDIT:[/b] Just noticed that IE is giving me this error in its error icon in the bottom left:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Error: 'document.unbrand' is null or not an object[/quote]
Here is my images that it is refering to:
[code]<img id="unbrand" src="preview.php" alt="UnBranded Preview" border="0px"/>
<img id="branded" src="preview.php" alt="Branded Preview" border="0px"/>[/code]

Share this post


Link to post
Share on other sites
fingers crossed .... try adding a name to it <img name="whatever" etc.

[a href=\"http://www.htmlgoodies.com/tutorials/web_graphics/article.php/3479941\" target=\"_blank\"]http://www.htmlgoodies.com/tutorials/web_g...cle.php/3479941[/a]

Share this post


Link to post
Share on other sites
[!--quoteo(post=350712:date=Mar 1 2006, 06:05 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Mar 1 2006, 06:05 PM) [snapback]350712[/snapback][/div][div class=\'quotemain\'][!--quotec--]
fingers crossed .... try adding a name to it <img name="whatever" etc.

[a href=\"http://www.htmlgoodies.com/tutorials/web_graphics/article.php/3479941\" target=\"_blank\"]http://www.htmlgoodies.com/tutorials/web_g...cle.php/3479941[/a]
[/quote]
Spot on! Thanks a bunch AndyB :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.