1

I have dynamically created images (recorder thumbnails) in javascript. I want to send the image path for this image to another file.

I think I can not get the image ID. I can not go to another file at all. The image is closed.

window.onload = function() {
    var message = {id : 'vodList'}
    sendMessage(message);


    document.getElementById(bb).addEventListener('click', function() { vodPlayer(); });
}

ws.onmessage = function(message) {
    for (var i=0; i<parsedMessage2.length; i++){
    createImage = document.createElement("img");
    createImage.setAttribute('src', parsedMessage2[i].vod_thumbnail);
    createImage.setAttribute('alt', '100%x280');
    createImage.setAttribute('height', '280px');
    createImage.setAttribute('width', '100%');
    createImage.setAttribute('id', 'vodThumbnailId');
    document.getElementById('vodListId').appendChild(createImage);

    vodPath = JSON.stringify(parsedMessage2[i].vod_path);
  }
}

function vodPlayer() {
    var form = document.createElement('form');
   form.setAttribute('charset', 'UTF-8');
   form.setAttribute('method', 'Post');
   form.setAttribute('action', 'vodPlayer.html');

    var hiddenField = document.createElement('input');
                     hiddenField.setAttribute('type', 'hidden');
                     hiddenField.setAttribute('name', 'vodPath');
                     hiddenField.setAttribute('value', vodPath);
                     form.appendChild(hiddenField);

document.body.appendChild(form);
                     form.submit();

}

I hope you can help me.

sera
  • 73
  • 1
  • 9
  • 2
    Possible duplicate of [How to Create a Form Dynamically Via Javascript](https://stackoverflow.com/questions/6964927/how-to-create-a-form-dynamically-via-javascript) – Hien Nguyen Apr 21 '19 at 04:12
  • 1
    The wording of the question title and the question itself is so different that I'm not sure what you are trying to do? If you are trying to know how to dynamically generate a form via JS, then check out the comment. Otherwise, please rephrase the question title to be more specific to your query – Samleo Apr 21 '19 at 04:45

0 Answers0