Question: I am trying to embed javascript in php's echo. 
I want to have a button saying "Continue??".
If the user presses "Ok" then `upload.php` should execute. 
If the user presses "Cancel" then he should get a popup.
Could you let me know where's the error in the following code. I see a button saying "Continue" but the `onclick` event doesn't work.

```
echo "<form name=myform>";
echo "<input type=button value=\"Continue? \"";
echo "onClick=\"if(confirm('Sure to continue'))";
 echo "<form enctype=\"multipart/form-data\" action=\"upload.php\" method=\"POST\"> </form>";
echo "else alert('As you wish')\">";
echo "</form>";

```

Answer: 
```
<form name=myform><input type=button value="Continue? "onClick=\"if(confirm('Sure to continue'))<form enctype="multipart/form-data" action="upload.php" method="POST"> </form>else alert('As you wish')"></form>

```

This is what your HTML looks like. It is not even remotely valid. Try this instead:

```
<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="submit" value="Continue?" onClick="if( confirm('Sure to continue?')) return true; alert('As you wish'); return false;" />
</form>

```
The first step would be to look at the generated HTML code. 

* If it isn't what you expect, then it can give you clues to what is wrong.
* If it is what you expect, the error isn't in the php
code.