using jQuery ajax to populate input field with results of a jQuery

using jQuery ajax to populate input field with results of a jQuery

I have and TRANS. CODE in my HTML:

 [HTML]

                  <tr>

                    <td>TRANS. CODE:</td>

                    <td>

                      <input id="TCODE" type="text" name="TCODE" size="3" maxlength="3" value="$TCODE" onblur="setStyleBlur(this.id);" onfocus="setStyleFocus(this.id);" />

                       <div style="display: inline;" id="TABCDES"> <span><b><font size="35" color="$color">$TABCDES</b></font></span></div><br>

                    ADJ/CN DESCRIPTION:&nbsp;&nbsp;

                      <input id="ACDESC" type="text" name="ACDESC" size="35" maxlength="35" value="$ACDESC" onblur="setStyleBlur(this.id);" onfocus="setStyleFocus(this.id);" />

                    </td>

                  </tr>

  [/HTML]

 

in the function valtscode that is excuted by javascript below:

    <script>

            $(document).ready(function() {

                        var select = $("#TCODE");

                       

                        select.blur(valtscode);

      });

 

                        function valtscode() {

 

                                    $.ajax({

                                                type: "POST",

                                                url: "fmadjclm.php",

                                                data: {

                                                            'task'   : 'valtscode',

                                                            'TCODE' : jQuery('#TCODE').val(),

                                                },

                                                success: function(data){

                                                            $('#TABCDES').html(data);

                                                            $('#ACDESC').html(data);

                                    }

                        });

      }

            </script>

 

The function valtscode below:

 

function valtscode()

{

            // Validate Transaction Code Return TABCDES from file TABCD

            // Make all global variables available here

            foreach($GLOBALS as $arraykey=>$arrayvalue)

            {

                        if ($arraykey != "GLOBALS")

                        {

                                    global $$arraykey;

                        }

            }

           

            // Get the key field values which identify the record 

            $TCODE = xl_get_parameter('TCODE');

            // Fetch the row for page

            $sqlstr = 'SELECT

            TABCD.TABCDES

             FROM JMALIB/TABCD

             WHERE ' . 'TABCD.TABCODE = '' . xl_encode($TCODE, 'db2_search') . "'";

           

            $color="black";

           

            $sReturn = array();

           

            if (!$result = db2_exec($db2conn, $sqlstr))

            {

                        echo("<span style="color: red"><font font-family:"Arial" size="3">SQL Error! " .

                        db2_stmt_errormsg() . "</span>");

            }

            else

            {

                        $row = db2_fetch_assoc($result);

                       

                        if ($row)

                        {

                                    $TABCDES = $row['TABCDES'];

                                    $ACDESC = $TABCDES;

                                                                        echo("<span style="color: black"><font font-family:"Arial" size="3"><B>" . $TABCDES . "</B></span>");                                  

                        }

                        else

                        {

                                    echo("<span style="color: red"><font font-family:"Arial" size="3"><B>Invalid Account Status Code!</B></span>");

                        }

            }

            db2_close($db2conn);

}

 

Returns TABCDES with LOAN PENDING and I echo($ACDESC);  which shows:  LOAN PENDING

but the aJax in the javascript does not put THE RUSULTS "LOAN PENDING"  it in the input field for ACDESC?   which will have some added information keyed in by entry prson.

Can any tell me what is required to t put THE RUSULTS "LOAN PENDING"  it in the input field for ACDESC?

James R. Martin
J. Martin Associates