I have created a button using Javascript and I am trying to open a window with window.open(url). The "url" opens up correctly initially. But then I created another button and did the same as I did earlier but this time around the url redirection got messed up. Both the buttons now open up on the last url that I used. I want both the buttons to work exclusively and open the respective urls that have been mentioned in the code.
<div style="float:left;padding-right:30px;padding-bottom:30px;">
<div>
<img src="http://3.bp.blogspot.com/-7zqUR_RPEH8/VLxzHDIQXoI/AAAAAAAAAkM/388tnESCv9g/600/peacock-aeromech.jpeg" height="200px"
width="200px"/>
</div>
<div>
<button onclick="myFunction()">Try it</button>
<script type="text/javascript">
function myFunction() {
var btn = document.createElement("BUTTON");
window.open("http://dl.amazon.com/dl/peacock-aeromech/p/itmdzdt4jdseczzh?pid=BLCDCYYHCKHVJDJG&srno=t_1&query=Lego&offer=b%3Amp%3Ac%3A112f129912.&affid=saurabhsu1","_self")
}
</script>
</div>
</div>
<div style="float:left;padding-right:30px;padding-bottom:30px;">
<div>
<img src="http://3.bp.blogspot.com/-7OoAscM_6WI/VLxzGLzimNI/AAAAAAAAAj0/L424sw9xDIg/s1600/lego-school-bus.jpeg" height="200px" width="200px"/>
</div>
<div>
<button onclick="myFunction()">Try it</button>
<script type="text/javascript">
function myFunction1() {
var btn = document.createElement("BUTTON");
window.open("http://dl.amazon.com/dl/lego-school-bus/p/itmdxsxgj7gfdzgk?pid=BLCDXSXFP3UTMYEX&srno=t_1&query=Lego&offer=b%3Amp%3Ac%3A11eaee7b19.&affid=saurabhsu1","_self")
}
</script>
</div>
</div>