ccarrin2
01-07-2012, 01:03 AM
When you do an alert confirm you can make if statements to say if they click ok do this and if they click cancel stop the program. Well I am trying to make a prompt that first asks the user to enter in a url and after they do and click enter they url is wraped with img tags.
I would like to make it so that if the user clicks cancel the program ends b/c right now if the user click okay with no value the result is and if the user clicks cancel the result is null. Any step in the right direction would be greatly appreciated!
<script language="javascript">
function imgGenerator(){
var question=confirm("Would you like to share an image?");
if (question==true){
var obj=document.getElementById("mngl-board-post-input");
var imgurl = prompt("To Share an image paste the image url here");
var txt=document.createTextNode(""+imgurl+"");
obj.appendChild(txt);
}
else {}
}
</script>
I would like to make it so that if the user clicks cancel the program ends b/c right now if the user click okay with no value the result is and if the user clicks cancel the result is null. Any step in the right direction would be greatly appreciated!
<script language="javascript">
function imgGenerator(){
var question=confirm("Would you like to share an image?");
if (question==true){
var obj=document.getElementById("mngl-board-post-input");
var imgurl = prompt("To Share an image paste the image url here");
var txt=document.createTextNode(""+imgurl+"");
obj.appendChild(txt);
}
else {}
}
</script>