Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73935

Creating an image by scanning input Javascript

$
0
0

I have a posting system for a blog. The issue is when I try to post an image (which was inputed)by using the createElement() function of Javascript it just does not work.

HTML and Js code:

function publish() {
  var title = document.getElementById("title").value;
  var description = document.getElementById("description").value;
  var para = document.createElement("h3");
  var node = document.createTextNode(title);
  para.appendChild(node);

  var element = document.getElementById("posts");
  element.appendChild(para);

  var para = document.createElement("small");
  var node = document.createTextNode("--".concat(description, "--"));
  para.appendChild(node);

  var image = document.getElementById("posts")
  element.appendChild(para)
  var image = document.getElementById("image-file").value
  var para = document.createElement("img");
  var node = document.createTextNode(image);
  para.appendChild(node);
}
<button id="publish-button" onclick="publish()">Publish</button><p>Title</p><input class="Title" id="title"></input><p>Description</p><input class="Description" id="description"></input><p>Images</p><input id="image-file" type="file" /><h1>The Blog</h1><ul id="posts"></ul>

Viewing all articles
Browse latest Browse all 73935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>