The following seems to work
function searchContacts(form)
{
var searchString= document.search.searchString.value;
form.searchString.value= searchString;
}
...
Form 1:
<form name="search" >
<input type="text" name="searchString">
<button name="search"> Cerca </button>
</form>
...
Form 2:
<form name="changeInitialForm" method="post" action="AddressBookView.jsp" onSubmit="searchContacts(this);">
<input type="hidden" name="selectedInitial"/>
<input type="hidden" name="status" value="view"/>
<input type="hidden" name="searchString" />
</form>
Notice that searchContacts(this.form)
was replaced with searchContacts(this)
.
UPDATE after some precisions by the author of the question:
The onsubmit
event is not triggered when form.submit()
is called by some javascript code. Thus, what you need when you submit the form is to call searchContacts
separately, for example using
searchContacts(document.changeInitialForm);
document.changeInitialForm.submit();