1 Reply Latest reply: Aug 3, 2006 2:25 PM by Ronsweb RSS

    Looping problems

    Ronsweb Community Member

      I am doing a remote call and I am having problems dynamically generating the names of the cfform text fields.
      The i is in a loop, however, I slimmed it down into some basic code:
      <cfsavecontent variable="actionFilter">

      var i = 1;
      var inputname = "forInput_" + i;
      var fortext = inputname.text.toLowerCase();
      </cfsavecontent>

      What I am trying to get into the variable fortext is: forInput_1.text.toLowerCase();
      It is not getting the value of the forInput_1 field in the cfform.The input field is in a generated cfloop.
      I also slimmed down this code to make it simple. This is in the cfform. I did not include the cfloop tags.
      <cfformgroup type="vdividedbox" enabled="yes" visible="yes">
      <cfformgroup type="horizontal" visible="yes" enabled="yes">
      <cfinput type="text" name="forInput_#i#" width="120" label="Search for Subject" onchange="#actionFilter#" readonly="false">
      </cfformgroup>
      </cfformgroup>

      Any help is appreciated!

      Thanks,

      Ron
        • 1. Re: Looping problems
          Ronsweb Community Member
          <cfsavecontent variable="actionFilter">
          <cfoutput>
          //create connection
          var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection(" http://#cgi.HTTP_HOST#/flashservices/gateway/");
          //declare service
          var myService:mx.remoting.NetServiceProxy;
          </cfoutput>
          var totalcount = internalrecordcount.text + 1;
          for (var i = 1; i < totalcount; i++) {

          if (this["forInput_" + i].text != '')
          {
          var responseHandler = {};

          var data = this["data_" + i];
          var gridpanel = this["gridpanel_" + i];
          //put the controls in scope to avoid calling _root
          var data = data;
          responseHandler.onResult = function( results: Object ):Void {
          //when results are back, populate the cfgrid
          data.dataProvider = results;
          }
          responseHandler.onStatus = function( stat: Object ):Void {
          //if there is any error, show an alertrleb
          alert("Error while calling cfc:" + stat.description);
          }
          //get service
          myService = connection.getService("components.flashRemotingResponder", responseHandler );
          var fortext = this["forInput_" + i].text.toLowerCase();
          gridpanel.enabled=true;
          gridpanel.visible=true;
          data.visible=true;
          data.enabled=true;
          gridpanel.height=250;

          myService.qlbccsubjects(fortext);

          break;

          }
          }
          </cfsavecontent>