This is my code:
<input type="submit" value="Delete" onclick="del('Are you sure you want to Delete?')">
<script language="JavaScript">
function del(display)
{
var inputs = document.myform;
if(inputs[5].value != '')
{
confirm(display);
}
}
</script>
When I click either the “ok” or the “cancel”, they both did the same way (the OK way)
How can I make the “cancel” do what it is supposed to do?
NOTE: I have a form there that I didn’t include for the simplicity of question.
you need to add two
returnin your code (bothonclickattribute and insidedel()function). You should also return something if your conditioninputs[5].value != ''is false