Assign img' src dynamically

html, javascript

Solution

Fixed HTML (switched classes and IDs to make IDs unique) and added an image ID for simplicity:

<div id="msgStyle1" class="message">Waiting for image</div>
<div id="imgStyle1" class="message">
    <img src="" id="image" />
</div>

JS:

document.getElementById('image').src = 'http://yourImagePathHere';

See it work here: http://jsfiddle.net/N3rCm/

Problem

The page will display an image's url text correctly. But I am not sure how to assign the message to the img 's src to display the image. ``` <DIV class="msgStyle1" id="message">Waiting for image</DIV> <div class="imgStyle1" id="message"> <img src=whatneedtogohere /></div> function displayText(text) { console.log(text); document.getElementById("message").innerHTML=text; window.castReceiverManager.setApplicationState(text); }; ```

Original source