<script type="text/javascript"> 

function sure(){
msg = "Are you sure?";
return confirm(msg);


<form method='post' action='preview.htm'>

<textarea name='myMessage'></textarea>
<input type='submit' value='Preview'>
<input type='submit' value='Submit' 
onClick="this.form.action='action.htm';return sure()">

I have a code like the above.

There are two buttons, i.e, preview and submit at
If you click the button "preview," it will go to preview page.
If you click the button "submit," an alert with confirm button and cancell button will pop.

if you click the confirm button, it will go to action.htm.
if you click the cancell button, it will stay there.

I have a problem with the code above.

If you click the button "preview" for the first time, it will go to "preview.htm."

if you click the button "preview" after you click the button "cancell" in the alert, it goes to action.htm instead of preview.htm although you click the button "preview."

How can I make it to always go to preview.htm when you click the button "preview?"