Jump to content


Photo

**SOLVED** Reloading an image


  • Please log in to reply
2 replies to this topic

#1 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 01 March 2006 - 04:39 PM

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?
<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>
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!

EDIT: 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:
<img id="unbrand" src="preview.php" alt="UnBranded Preview" border="0px"/>
<img id="branded" src="preview.php" alt="Branded Preview" border="0px"/>


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 01 March 2006 - 06:05 PM

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]
Legend has it that reading the manual never killed anyone.
My site

#3 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 01 March 2006 - 07:12 PM

[!--quoteo(post=350712:date=Mar 1 2006, 06:05 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Mar 1 2006, 06:05 PM) View Post[/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 :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users