I have a few problems at present with what I though was a fairly simple piece of Javascript. When a specific event occurs a Javascript function is called which alters the HTML that appears between two Div tags by the use of document.getElementById(divname).innerHTML.
This works fine. However, one of these changes an image so that it displays the image chosen in a file selection text box. This works fine on all the desktops I have tried (four), but gives no image [ie little traingle, circle, square icon] on all the laptops (four). It does not appear security settings or the browser, but I am in the dark as to why laptops would behave differently to desktops in this regard.
Has anyone ever encounter this problem?
Thanks,
Robert
InnerHTML Problem
Moderator: General Moderators
Re: InnerHTML Problem
I fear more code is needed... I don't quite understand the problem from your post.
Re: InnerHTML Problem
Specifically, where are the images stored, that you want displayed under various situations? Is it possible that when you migrated the script to the laptops, you simply neglected to transfer the image files? Or that the path to the images is different?
Re: InnerHTML Problem
At the moment you visit a page, and that pages shows you a holding image (stored on the server), and an input box for your file
Then you click the input box and locate your file. Which activates the Jscript
Which should (and does on the desktops) then display the image of the jpeg which is on the drive of the machine.
Thanks, Robert
P.S I know the file paths in the input box are working because if you proceed to upload it does move the correct file from the laptop to the server, even though it won't display the image.
Code: Select all
<div id="obverse" width = 300>
<img src="icons/uploadobverse.jpg" width = 250>
</div>
<br>
<input name="obvimage" type="file" onchange='showLocalImage(this.value, "obverse", 250)'>
Code: Select all
function showLocalImage(imgname, divname, size){
document.getElementById(divname).innerHTML='<img src="'+imgname+'" width ='+size+'>';
}Thanks, Robert
P.S I know the file paths in the input box are working because if you proceed to upload it does move the correct file from the laptop to the server, even though it won't display the image.
Re: InnerHTML Problem
Not sure why this wouldn't work, are the laptops using a different browser.
I have had funny things happen with using innerHTML like this before. I find it best to create an image object and append that to the DIV.
I have had funny things happen with using innerHTML like this before. I find it best to create an image object and append that to the DIV.