Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
5 replies Latest Post - ‏2013-12-20T07:29:58Z by makvell
JaydeepSapariya
JaydeepSapariya
14 Posts
ACCEPTED ANSWER

Pinned topic Simple Validation using Java Script

‏2012-10-06T10:21:26Z |
Hi Folks,
I wanted to implement couple of validation in my coach using java script. I am using new coach of BPM 8.0. My requirement is as follows...

I have defined one selection box & 4 output text attributes in my coach. On the selection of particular value from Drop-down (Ex. Selection of Customer Name from drop-down) remaining 4 attributes should auto populate using Ajax service (Ex. Customer Country,Customer City, Address , Zip Code).

I was trying to add Java script code in Coach View by add dojo.query("<CONTROL ID OF DROP-DOWN"); & adding onChange event but some how i am unable to get coach controls into Coach View.

Also need to understand how to call Ajax service using Java script/dojo. Any help will be useful. Thanks.
Updated on 2012-10-12T17:30:52Z at 2012-10-12T17:30:52Z by JaydeepSapariya
  • kolban
    kolban
    3315 Posts
    ACCEPTED ANSWER

    Re: Simple Validation using Java Script

    ‏2012-10-08T21:24:32Z  in response to JaydeepSapariya
    Hi there. It sounds like what you want is to detect the change of value of the variable bound to the selection box. When the selection box value changes, you then want to invoke an Ajax service which, when it returns, will return an object which has 4 properties associated with it. Each of these properties will be used to change the value of variables associated with an Output text coach view.

    Is that about the size of it?

    If this is correct, we can next start to discuss possible algorithms to achieve this goal.

    Neil
    • JaydeepSapariya
      JaydeepSapariya
      14 Posts
      ACCEPTED ANSWER

      Re: Simple Validation using Java Script

      ‏2012-10-12T17:30:52Z  in response to kolban
      Thanks kolban for your input.

      Yes your understanding is correct. I have same requirement. one small disconnect, i have added selection box & other Output box under coach.

      Yes i want to trigger/catch onchange event whenever there is change in drop down value. On the base of selected value, i want to call Ajax service & pull out required properties from DB & set it to Output box.

      Major challange i am facing is how to catch onchange event of selection box. i tried to using below code but its not working.

      var selectElement = dojo.byId("selectionbox");
      var onClickHandle = dojo.connect(selectElement , "onchange", this, function(newValue){
      alert("Hello");
      }

      i have trace DOM code & found that DOM code is internally converting selectionbox element into input text box. Hence we can't associate onchange event to drop down as it wont work with text box.I have attached snap shot for same.

      Thanks.
      • P.Singh
        P.Singh
        2 Posts
        ACCEPTED ANSWER

        Re: Simple Validation using Java Script

        ‏2013-12-20T03:09:20Z  in response to JaydeepSapariya

        I am facing similar issues . Could you please share the resolution of this problem .

         

        Also, how do I make the visibility of textboxes dependent on checkbox within a form .

        I want that if I select a certain radio button eg. true, the textbox should be made hidden.

        Any  help will be useful . Thanks .

        • kolban
          kolban
          3315 Posts
          ACCEPTED ANSWER

          Re: Simple Validation using Java Script

          ‏2013-12-20T06:37:29Z  in response to P.Singh

          In v8.5 of the product, visibility of Coach Views can be controlled by variable settings.  For example, if the checkboxes value changes from true to false or visa versa, that can change the state of the visibility of a different control.

          Neil

      • makvell
        makvell
        269 Posts
        ACCEPTED ANSWER

        Re: Simple Validation using Java Script

        ‏2013-12-20T07:29:58Z  in response to JaydeepSapariya

        Hi.

        Simple way: clone select coach view, in load event handler find this code

        onChangeHandle = connect.connect(filteringSelect, "onChange", this,
            function() {
                ...

                //add this line (change event name :) /add any params like: connect.publish("my_select_changed", {someParam: someParamValue});)
                connect.publish("i'm changed!!!");
            });

         

        Now you can subscribe for this event and react.