4 Replies Latest reply on Dec 17, 2009 8:28 AM by user1234

    Passing reference to current form to javascript

    schenger

      Hey,

       

      i would like to disable all inputs in a form during ajax request. Therefore i call a javascript function and i try to pass the current form reference. The problem in javascript is the form reference undefined. Can i pass current form reference like: disableElements(this.form);

       

      <rich:inputNumberSlider id="slider"
          value="#{node.submittedValue }"
          valueChangeListener="#{handler.valueChanged }"
          label="#{node.name }"
          inputPosition="top"
          width="400"
          showInput="true"
          enableManualInput="true"
          minValue="#{node.min}"
          maxValue="#{node.max}">
          <a4j:support event="onchange"
              onsubmit="disableElements(this.form);"
              requestDelay="1000" status="commonstatus"
              reRender="part" />
      </rich:inputNumberSlider>

       

      or is it possible to block only a part of the page with modalpanel?

       

      thank you very much

        • 1. Re: Passing reference to current form to javascript

          In the javascript you can directly access the "form" object many way, like

          var frm = document.forms[index];

          here by using index you can get the required form if there are multiple form inside same document.

           

          you can directly get form object of element like this,

          var form = element.form;

          if you pass the object 'this'   check what you are getting the in javascript  by giving alert like alert(object.id)

          • 2. Re: Passing reference to current form to javascript
            ilya_shaikovsky
            1 of 1 people found this helpful
            • 3. Re: Passing reference to current form to javascript
              schenger

              Hi Deb Dutta,

               

              thank you for reply.

               

              In the javascript you can directly access the "form" object many way, like

              var frm = document.forms[index];

              here by using index you can get the required form if there are multiple form inside same document.

              In my case this is a portal page so there are many forms and the index of the form can be different. Also i cannot give id to the forms so i could not use

              document.getElementById('formid'). They are generated elsewhere.

               

              if you pass the object 'this'   check what you are getting the in javascript  by giving alert like alert(object.id)

              I've tried that. I can see 'undefined' in the alert message.

               

              maybe other ideas?

               

              thanks a lot.

              • 4. Re: Passing reference to current form to javascript

                hmm...understood,

                for the element  get the parent  form id where it is included  and can pass it like this

                 

                  onsubmit="disableElements('formid);


                then in the js method get the form object,

                 

                var formobj = document.getElementById(formid);