0

How to display an image using JavaScript from an array creating in JavaScript.

Any help please?

Thanks.

2
  • Display it where? Do you have an HTML page, maybe? They make these sort of things much easier. Commented Jul 15, 2010 at 15:22
  • Yes, i have a html page. sry forgot to mention that but the value is stored in an object array. Commented Jul 15, 2010 at 15:23

2 Answers 2

3

If you've got an image tag in your HTML layout, with a given id, you can control its content with javascript:

function updateFullImage(id, url) {
    var img = document.getElementById(id);
    img.src = url ;
}

and the browser (FF at leat) will automatically reload your image

Sign up to request clarification or add additional context in comments.

Comments

1

You can create an image in JavaScript: var img = new Image(); img.src = "path-to-image"; and then add it to the DOM (depending on if you're using a js library like jQuery or not this will vary in complexity). Can you be more specific as to your circumstances?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.