All pastes #770673 Raw Edit

loudmouthman

public text v1 · immutable
·published 2007-11-12 14:21 UTC
rendered paste body
The Brief:

The following code updates a text box with the result of the material code, what I then intend to do is call another script to update the organisation OrderHeader with the selected recordno number ( returned in li.value )
supphint is used to hang the Ordered List upon for Selection.
supplierSearch is the textbox where the supplier name is returned.
orgTitlelookup looks up the supplier name and recordno number
getSupp is a function called after update and should pass three things to orgdetailsUpdate
which are recordno which is the orderheader recordnumber, value which is the field content ( in this case the supplier recordno ) and field which is the field name in the orderheader to update , 

Im using Scriptaculous for the ajax stuff here.


The problem
Since li.value is dynamic and passed to the function how do I pass it back into the code for orgdetailsUpdate as the value. the li.value when inspected with alert() contains the correct value so how do/can I pass the string into the code below

The problem is at line 10   &value=' . li.value  .   '   

Any thoughts, help, advice is appreciated




1 <div id=supphint ></div>
2 <script type=text/javascript >
3  new Ajax.Autocompleter(                       \'supplierSearch\' ,
4                                                 \'supphint\' ,
5                                                \'./ajax/orgTitlelookup.php?type=Supplier\',
6                                                { afterUpdateElement : getSupp })   ;
7                                                function getSupp( supplierSearch,li )
8                                                     { new Ajax.Updater(
9                                                                         \'supphint\', 
10                                                                         \'./ajax/orgdetailsUpdate.php?recordno=' . $order .  '&value=' . li.value  .   '  &field=suppcode   \', 
11                                                                         {asynchronous:true, 
12                                                                            parameters:Form.serialize(\'supplierForm\') ,
13                                                                               onComplete: supplierAddress    });   
14                                                      function supplierAddress( ) {
15                                                                         var ret = document.getElementById(\'supphint\').innerHTML ;
16                                                                         document.getElementById(\'supplier\').innerHTML = ret;
17                                                                          document.getElementById(\'supphint\').innerHTML = \'\';                                                                                                                                                                                                                             
18                                                                          return true;  } ;
19                                                                          return true;   };
20                                           </script> ' );


problem resolved. I was being brain dead by thinking the focus of the script at that point was PHP when in fact it was justa  URL string that javascript was still handling. As a result the following is my fix correct Code. The Fix on Line 14 looks like this 

'&value=\' + li.id + \'





1 $supplierSearch = array('text',
2                                        'textfield',
3                                        'supplierSearch',
4                                        'Supplier',
5                                        $supplierTitle
6                                        ,'',
7                                        '<div id=supphint ></div>
8                                           <script type=text/javascript >
9                                           new Ajax.Autocompleter(
10                                                \'supplierSearch\' ,
11                                               \'supphint\' ,
12                                                \'./ajax/orgTitlelookup.php?type=Supplier\',
13                                                { afterUpdateElement : getSupp })   ;
14                                                function getSupp( supplierSearch,li ){  new Ajax.Updater(\'supphint\', \'./ajax/orgdetailsUpdate.php?recordno=' . $order . '&value=\' + li.id + \' &field=suppliercode   \', {asynchronous:true, parameters:Form.serialize(\'supplierForm\') , onComplete: supplierAddress    });   function supplierAddress( ) {var ret = document.getElementById(\'supphint\').innerHTML ;  document.getElementById(\'supplier\').innerHTML = ret; document.getElementById(\'supphint\').innerHTML = \'\'; return true;  } ;return true;   };
16                                           </script> ' );