I have a form:

```
  <form name="orderform" onsubmit="submitForm()">
 HTML HERE
.
.
.
<button type="submit" name="submitbutton"   id="submitbutton">Submit</button>

```

and the functions:

```
function submitForm()
{
 submitted = true;
 goHome(submitted);
}

```

and

```
function goHome(submitted)
{
  if(redirect == submitted)
{
  alert("form submitted");
  document.location.href = "index.html";
}
}

```

I'm trying to make my page display an alert message and then redirect to index.html after the form is submitted but i can't seem to get it right in any way. 
I've tried using `onClick` at submit button or submitting the form purely with Javascript (`document["orderform].submit();` and `document.getElementById("orderform");`) but that did'nt work.

My guess was that these functions were being executed at the same time as the submission, leading the submission to execute over them. So, I added `setTimeout` for `function goHome();` to be executed or tried `window.onload = goHome();` but nothing seems to be working.

Any suggestions?

PS: I'm not using jQuery.