Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Need to add a separator to results

    What can I add to this code to ensure the results are separated by a
    or line? When I run the script the results return which each section on top of the othe with no sperataor so it's hard to determine where the next one starts. All assitance is much appreciated.





    Code:
     <script type="text/javascript">
        // input field descriptions
        var desc = new Array();
        desc['PROC_CODE'] = 'Procedure Code';
        desc['MEDICARE'] = 'Medicare Advantage';
        desc['STATUS'] = 'Procedure';
        desc['ID'] = 'Specialty';
        desc['SYS_APP'] = 'Precert Type';
        desc['SUBMITTER'] = 'Review Type';
        desc['EMAIL'] = 'Guidelines';
        desc['ADD_CPT'] = 'Additional Information for CPT';
        desc['change'] = 'Prior Change Information';
    
        <!--------->
        desc['PROC_CODE1'] = 'Procedure Code';
        desc['MEDICARE1'] = 'Medicare Advantage';
        desc['STATUS1'] = 'Procedure';
        desc['ID1'] = 'Specialty';
        desc['SYS_APP1'] = 'Precert Type';
        desc['SUBMITTER1'] = 'Review Type';
        desc['EMAIL1'] = 'Guidelines';
        desc['ADD_CPT1'] = 'Additional Information for CPT';
        desc['change1'] = 'Prior Change Information';
    
        <!--------->
        desc['PROC_CODE2'] = 'Procedure Code';
        desc['MEDICARE2'] = 'Medicare Advantage';
        desc['STATUS2'] = 'Procedure';
        desc['ID2'] = 'Specialty';
        desc['SYS_APP2'] = 'Precert Type';
        desc['SUBMITTER2'] = 'Review Type';
        desc['EMAIL2'] = 'Guidelines';
        desc['ADD_CPT2'] = 'Additional Information for CPT';
        desc['change2'] = 'Prior Change Information';
        <!--------->
        desc['PROC_CODE3'] = 'Procedure Code';
        desc['MEDICARE3'] = 'Medicare Advantage';
        desc['STATUS3'] = 'Procedure';
        desc['ID3'] = 'Specialty';
        desc['SYS_APP3'] = 'Precert Type';
        desc['SUBMITTER3'] = 'Review Type';
        desc['EMAIL3'] = 'Guidelines';
        desc['ADD_CPT3'] = 'Additional Information for CPT';
        desc['change3'] = 'Prior Change Information';
        <!--------->
        desc['PROC_CODE4'] = 'Procedure Code';
        desc['MEDICARE4'] = 'Medicare Advantage';
        desc['STATUS4'] = 'Procedure';
        desc['ID4'] = 'Specialty';
        desc['SYS_APP4'] = 'Precert Type';
        desc['SUBMITTER4'] = 'Review Type';
        desc['EMAIL4'] = 'Guidelines';
        desc['ADD_CPT4'] = 'Additional Information for CPT';
        desc['change4'] = 'Prior Change Information';
    
        <!--------->
        desc['PROC_CODE5'] = 'Procedure Code';
        desc['MEDICARE5'] = 'Medicare Advantage';
        desc['STATUS5'] = 'Procedure';
        desc['ID5'] = 'Specialty';
        desc['SYS_APP5'] = 'Precert Type';
        desc['SUBMITTER5'] = 'Review Type';
        desc['EMAIL5'] = 'Guidelines';
        desc['ADD_CPT5'] = 'Additional Information for CPT';
        desc['change5'] = 'Prior Change Information';
    
    
    
        function CopyFields(){
            var copytext = '';
            for(var i = 0; i < arguments.length; i++){
                copytext += desc[arguments[i]] + ': ' + document.getElementById(arguments[i]).innerText + '\n' ;}
            var tempstore = document.getElementById(arguments[0]).innerText;
        window.clipboardData.setData('Text', copytext + '\n');}  
    
         function show(ele) {
                 var srcElement = document.getElementById(ele);
                 if(srcElement != null) {
       if(srcElement.style.display == "block" ) {
              srcElement.style.display= 'none';
        }
            else {
                   srcElement.style.display='block';
            }
            return false;
               }
       }</script>
    Here is the call for copyFields()

    Code:
      <a href="#"  onClick="CopyFields(
              'PROC_CODE','MEDICARE', 'STATUS', 'ID', 'SYS_APP', 'SUBMITTER','EMAIL','ADD_CPT','change',
          'PROC_CODE1','MEDICARE1', 'STATUS1', 'ID1', 'SYS_APP1', 'SUBMITTER1','EMAIL1','ADD_CPT1','change1',
              'PROC_CODE2','MEDICARE2', 'STATUS2', 'ID2', 'SYS_APP2', 'SUBMITTER2','EMAIL2','ADD_CPT2','change2',
              'PROC_CODE3','MEDICARE3', 'STATUS3', 'ID3', 'SYS_APP3', 'SUBMITTER3','EMAIL3','ADD_CPT3','change3',
              'PROC_CODE4','MEDICARE4', 'STATUS4', 'ID4', 'SYS_APP4', 'SUBMITTER4','EMAIL4','ADD_CPT4','change4',
              'PROC_CODE5','MEDICARE5', 'STATUS5', 'ID5', 'SYS_APP5', 'SUBMITTER5','EMAIL5','ADD_CPT5','change5');"><b>Cli              ck To Copy ALL data returned on this page</b></a

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Look for the name to start with "PROC_CODE" and put in a separator?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Not exactly. Here is what the copy function putts out once you run it. As you can see all the functions are right on top of each other.. BUt if you scroll down you will see the desired result.

    Current

    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:
    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:
    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:
    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:
    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:
    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:


    Desired Result

    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:

    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:

    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:

    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:

    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:

    Procedure Code:
    Medicare Advantage:
    Procedure:
    Specialty:
    Precert Type:
    Review Type:
    Guidelines:
    Additional Information for CPT:
    Prior Change Information:

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Sorry, I don't see your objection.

    How hard is it to modify CopyFields to look at the names being passed and, every time it sees a name that *STARTS* with "PROC_CODE", simply insert a separator?

    I do also have to say I don't understand the point of specifying all those fields in the CopyFields function call. Why not simply do CopyFields(desc) to automatically get all the fields noted in your desc "array" (which isn't really an array, but never mind).

    On a parallel note: You could have much more neatly and compactly created desc thusly:
    Code:
    var desc = {
        'PROC_CODE' :  'Procedure Code',
        'MEDICARE' :  'Medicare Advantage',
        'STATUS' : 'Procedure',
       ... etc. ...
        'ADD_CPT5' : 'Additional Information for CPT',
        'change5' : 'Prior Change Information'
    };
    Also, I don't understand the point of having "PROC_CODE" for the first instance and then "PROC_CODE1", "PROC_CODE2", etc. Why not be consistent and name the first instances with a zero: "PROC_CODE0", "MEDICARE0", etc.?

    And if you did *THAT*, then you could avoid all the duplication.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Here. Why not keep it dirt simple, like this:
    Code:
    var desc = {
        'PROC_CODE' :  'Procedure Code',
        'MEDICARE'  :  'Medicare Advantage',
        'STATUS'    :  'Procedure',
        'ID'        :  'Specialty',
        'SYS_APP'   :  'Precert Type',
        'SUBMITTER' :  'Review Type',
        'EMAIL'     :  'Guidelines',
        'ADD_CPT'   :  'Additional Information for CPT',
        'change'    :  'Prior Change Information'
    };
    
    function CopyFields( )
    {
        var copytext = "";
        var suffix = "";
        for ( var i = 0; i <= 5; ++i )
        {
            if ( i > 0 )
                suffix = i;
            }
            for ( var name in desc )
            {
                var id = name + suffix; // so PROC_CODE, but then PROC_CODE1, etc.
                copytext += name + ": " + document.getElementById(id).innerText + "\n";
            }
            copytext += "\n"; // or whatever other separator you want to use
        }  
        window.clipboardData.setData('Text', copytext + '\n');
    }
    And if you would append the zero to the first instance of each name (that is, use PROC_CODE0, MEDICARE0, et al.) then we could simplify the code even further.
    Code:
    function CopyFields( )
    {
        var copytext = "";
        for ( var i = 0; i <= 5; ++i )
        {
            for ( var name in desc )
            {
                copytext += name + ": " + document.getElementById(name + i).innerText + "\n";
            }
            copytext += "\n";
        }  
        window.clipboardData.setData('Text', copytext );
    }
    Last edited by Old Pedant; 05-07-2013 at 02:32 AM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •