Jump to content

**SOLVED** Reloading an image


zq29

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]
Link to comment
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]
Link to comment
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 :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.