Hello! Just started learning javascript:
anyway just messing around trying to make a program where you enter a value into each of the two prompt boxes and the multiplied value of the two is show. I've got this:

function showprompt()
{
r=prompt("Enter first number:","");
if(r!=null && r!="")
{
x=r;
}
{
r2=prompt("Enter second number","");
if(r2!=null && r2!="")
{
	y=r2
}
{
	document.write(x*y);
}
}
}

So, it works. But the button (I use a button in the html

<button type="button" onclick="showprompt()">Hello!</button>

) Dissapears. Also any optimisation of the code would be cool to see, but make that seperate to the solution as to how to make the button not dissapear!!

Any help greatly appreciated!

Member Avatar for stbuchok

Can you show all the code for the entire page?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.