You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Johnson <jo...@soho.club.tw> on 2004/11/07 16:00:53 UTC

a method for controling focus in cform when on-value-changed

Hi!

I think it's a big problem for controling focus in cform,because when on-value-changed submit,the focus loss,this will cause unconvient to user.
so I try several method.
1. handle the xsl in on-value-changed,but the new page will became default value of the xsl file was.
2. use xsl:param,it works one time,the second time the value of xsl:param became a fixed value,because in on-value-changed,the sitemap not performed.
3. use session context , the same to xsl:param
4. try to judge the name of forms_submit_id , the first page sended, but I can't find it in second page, maybe there're a method to pass it from server to cliend.
5. add a hidden widget,it works.
A. in form definition file, add a field,put to the first column for the form.
B. in flowscript, set the init value for the widget to 2 for init display.
C. in template,assign the widget type to hidden.
D. add the following code in template or xsl

      <script type="text/javascript">
         var focusHandler = new Object();
         focusHandler.forms_onload = function() {
              var idx = document.forms['aaaaa'].elements[1].value;
              document.forms['aaaaa'].elements[idx].focus();
             }
        forms_onloadHandlers.push(focusHandler);
    </script>

E. in on-value-change change the widget's value to a proper one.

It seemed too complex,I prefer the method 4, but  I don't know how to get the forms_submit_id in the second page cliend side xsl, maybe others can teach me.

Best Regards

johnson