Thanks Adrien - I guess we wrote e-mails at the same time... as stated
in the previous e-mail I have just tried such a solution. Still I wish
there was a more standard way...
R.
Adrien FOURES wrote:
Hello Randahl,
If i have understand your question, try this:
<body onload="test()">
[...]
<script language="Javascript">
function test(){
document.getElementById('mySecretAndHiddenForm:sendProperties').click();
}
</scipt>
</body>
or
<body>
[...]
<script language="Javascript">
test();
function test(){
document.getElementById('mySecretAndHiddenForm:sendProperties').click();
}
</script>
</body>
Adrien
Randahl Fink Isaksen wrote:
I have a page which detects some browser properties (browser window
width, etc.) and I would like to submit these capabilities
automatically using a javascript like
document.forms['mySecretAndHiddenForm'].submit();
However this does not seem to work. In other words: Automatically
invoking submit from javascript does not seem to yeild the same
results as making the user click a form button manually - probably
because the action of the form is never set.
Is there a standard way to submit hidden form fields using
javascript? Now I guess I could manually set the action of the form
to something like
"#{evaluationBean.evaluate}"
using javascript and then call submit afterwards, but it does not
feel right to hard-code this into my javascript - I sence there has
got to be a better, cleaner way.
Any suggestions would be highly appreciated.
Randahl
Here follows my forms JSF code:
<h:form id="mySecretAndHiddenForm">
<h:inputText id="windowInnerWidth"
value="#{evaluationBean.windowInnerWidth}"/>
<h:inputText id="windowInnerHeight"
value="#{evaluationBean.windowInnerHeight}"/>
[...]
<h:commandButton
id="sendProperties"
type="SUBMIT"
action="#{evaluationBean.evaluate}"
/>
</h:form>