Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:49:34+00:00 2026-06-08T21:49:34+00:00

I am attempting to truncate a book title that is retrieved from my db

  • 0

I am attempting to truncate a book title that is retrieved from my db to print on a bar code label. I can’t truncate it from the query as I need to entire title to appear in a table on the same page. Here is what I have:

   $.ajax({
        type: "POST",
        url: "advanceProcess.php",
        dataType: "json",
        data: ({sourceID: $('#sourceID').val(), fromDate: $('#fromDate').val(), toDate: $('#toDate').val()}),
        success: function(data){
            if(data.isbn == null ){
                $("#acctRecords").append('<tr><td>No Records Found</td></tr>');
            }else{
                //append general data
                for(var x=0;x<data.isbn.length;x++)
                {
                    $("#acctRecords").append('<tr><td id="tableSKU">'+data.tempsku[x]+
                    '</td><td id="tableISBN">'+data.isbn[x]+
                    '</td><td id="tableTitle">'+data.title[x]+
                    '</td><td id="tableOrderid">'+data.orderId[x]+
                    '</td><td id="tableQtyBought">'+data.quantity[x]+
                    '</td><td id="tableCost">'+data.cost[x]+
                    '</td><td id="tabledateCreated">'+data.dateCreated[x]+
                    '</td><td id="tableWeight">'+data.weight[x]+
                    '</td><td id="tableCheckNumber">'+data.checkNumber[x]+'</td></tr>');
                }// end of for loop
                //refreshes the tablesorter plugin
                $("#acctRecords").trigger("update");
    //Print the bar codes
    sku = data.tempsku;
    title = data.title[x];
    //console.log(JSON.stringify(data));
    title = title.substr(0,16);
    var x=0;
    for (x=0;x<title.length;x++)
    {   
        first += '$("#'+indexGlobal+'").barcode("'+sku[x]+'", "codabar",{barHeight:40, fontSize:30, output:"bmp"});';
        second += '<div class="wrapper"><img src="../images/temp.jpg" /><div id="'+indexGlobal+
        '"></div><div class="fullSKU">&nbsp &nbsp &nbsp '+sku[x]+'</div><br/><div class="title">'+title[x]+
        '</div></div><br/><div class="page-break"></div>';
        indexGlobal++;
    }           

Everything workd fine, except the title is too long. Currently I am getting an error that states: TypeError: title.substr is not a function. I have done some research on here and on Google and it seems that my code is correct. Any ideas?

EDIT: here are the results of the JSON:

"title":["Understanding and Applying Medical Anthropology","The Ethical Chemist : Professionalism and Ethics in Science","Magic, Witchcraft, and Religion: A Reader in the Anthropology of Religion","Principles of Cancer Biology","AIDS and Accusation: Haiti and the Geography of Blame","In Search of Respect: Selling Crack in El Barrio (Structural Analysis in the Social Sciences)"] 

EDIT 2: I updated the script to show the entire ajax call and how the results are returned.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:49:36+00:00Added an answer on June 8, 2026 at 9:49 pm

    You are using multiple titles, in order to just get the first one from the array:

    title = data.title[0];
    title = title.substr(0,16);
    

    If you want to build barcodes for each title:

    for(x=0; x<data.title.length; x++)
    {
       title = data.title[x];
       title = title.substr(0,16);
    
       // Build barcode
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to print out a list of values from 2 different variables that are
I'm attempting to create an ajax function that returns a specific string from a
Attempting to parse json from a url requiring login. Including all my code here
I'm attempting to build a database table that holds zip code data (that is
Attempting to set up an automated texting service for customers, where people can text
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to make a NSObject called 'Person' that will hold the login details for
Attempting to change the files folder location in a Drupal site from /files to
Attempting to move an uploaded file so that it is saved in the directory,
I'm attempting to write a stored procedure in MySql that will take a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.