InnerHTML Problem

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
RobertBr
Forum Newbie
Posts: 11
Joined: Fri Oct 20, 2006 1:28 pm

InnerHTML Problem

Post by RobertBr »

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
Alan01252
Forum Newbie
Posts: 12
Joined: Sun Aug 03, 2008 3:20 pm

Re: InnerHTML Problem

Post by Alan01252 »

I fear more code is needed... I don't quite understand the problem from your post.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: InnerHTML Problem

Post by califdon »

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?
RobertBr
Forum Newbie
Posts: 11
Joined: Fri Oct 20, 2006 1:28 pm

Re: InnerHTML Problem

Post by RobertBr »

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

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)'>
 
Then you click the input box and locate your file. Which activates the Jscript

Code: Select all

function showLocalImage(imgname, divname, size){
  document.getElementById(divname).innerHTML='<img src="'+imgname+'" width ='+size+'>';
  }
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.
Alan01252
Forum Newbie
Posts: 12
Joined: Sun Aug 03, 2008 3:20 pm

Re: InnerHTML Problem

Post by Alan01252 »

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.
Post Reply