add a image from a url to a gallery html using js
<p>Hi i am new to javascript and have looked but can't seem to solve my problem.
I am looking to ask the user for a url to an image and add it to a gallery made using html and another js document. The gallery is fine just need to figure out a way to add a new img tag with the url inside it.</p>

<p>This is what i have so far:</p>

<pre><code>function getUrl() {
var url = prompt('Enter image URL');

if (url) { // Do string and URL validation here and also for image type
    return url;
} else {
    return getUrl();
}`.slider image.src = getUrl();`



    &lt;form action="" method="post" class="contact" id="contact" onsubmit="return getUrl()"&gt;
    &lt;label for="name"&gt;Add Image url:&lt;/label&gt;
        &lt;input type="submit" value="submit"&gt;
    &lt;/form&gt;

&lt;div class="slider"&gt;
    &lt;img src="gallery/img1.jpg" alt="image 1" /&gt;
    &lt;img src="gallery/img2.jpg" alt="image 2" /&gt;
    &lt;img src="gallery/img3.jpg" alt="image 3" /&gt;
    &lt;img id="image"/&gt;

    &lt;button class="prev"&gt;&amp;#60;&lt;/button&gt;
    &lt;button class="next"&gt;&amp;#62;&lt;/button&gt;
 &lt;/div&gt;
</code></pre>

<p>If you can help in anyway that would be great, thanks.</p>

<p>edit: My question was i wanted to add img tags to a gallery already in the html code but by not changing the src of any photos already there and just adding the tag each time a photo was added with the url of the photo.</p>