Hi!

 

I can give you an example of how I use javascript to do a "click" on a button. 
:)

 

You must remember that if your form id is "myForm", and the button's id is 
"myButton", the correct name of the button (element) in javascript is 
"myForm:myButton"

(This changes is you use the tomahawk components and set the forceId to true)

 

An example of a "generic" function in javascript:

 

function clickButton(formName, elementId)

{

 

      

      var elementToGet = formName + ":" + elementId;

 

      var form = document.forms[formName];

      

      var button = form.elements[elementToGet];

 

      button.click();

}

 

Hope this leads you in the right direction at least :)

 

Regards,

 

Eivind

________________________________

From: Romanowski, Tim [mailto:[EMAIL PROTECTED] 
Sent: 18. januar 2007 22:54
To: MyFaces Discussion
Subject: How to submit a form using javascript

 

I'm trying to integrate some components form Jack Slocum's yui-ext project [1], 
but have run into a problem in trying to submit a form or link in my JSF code 
from javascript.  The details are posted at [2].  The current information on 
MyFaces wiki at [3] has not helped (see the clickLink javascript function used 
with a hidden link at the bottom of the page); I'm not sure why, but I'm 
wondering if it has something to do with the scope of the function and the way 
it tries to access dom elements.  The first couple examples show how to call 
javascript from within a commandButton or commandLink, but I'm interested in 
doing the reverse-using javascript to execute a button or link.  If anyone 
could offer some insight, it would be greatly appreciated.  

 

Tim

 

[1] http://www.yui-ext.com/

[2] http://www.yui-ext.com/forum/viewtopic.php?t=2204

[3] http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces

 

 

Reply via email to