Hello, I was wondering if anyone can give me assistance on this. I have a jsp page. Inside it I have two javascript functions.

The first function, setValue, sets the value of a drop down list to "Test string input"

The second function, submitValue, submits the form.

I would like the page to submit the form once, automatically upon loading.

The problem I have is that it does submit the form, the page THEN reloads. Upon the page reload, the page submits the form again in an endless-submit loop.

Does anyone have any suggestions as to how I can automatically submit a form once upon loading, the page submits, reloads, and doesnt submit anymore.


I tried a counter within the submitValue but to no avail.
counter = 0;
function submitValue(){
while (counter < 1)
{
document.forms['siteAreaForm'].submit();
counter ++
return true;
}
return false;
}


This is the source code I have:

<script language="JavaScript">
var sArea = "Test string input";
counter = 0;

function setValue(){
myform.myselect.options[0].value=sArea;
}

function submitValue()
{
document.forms['siteAreaForm'].submit();

}

// note, I have to use window.onload instead of body onload
// because I am dealing with portlets.
window.onload = function(){
setValue();
submitValue();
}
</script>

<FORM method="POST"
name="siteAreaForm"
id="myform">
<SELECT id="myselect" name="siteAreaDropDn">
<OPTION value=''>Hello</OPTION>
</SELECT>
<input type="submit">
</FORM>