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 8530915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:21:53+00:00 2026-06-11T09:21:53+00:00

I have a piece of jquery which drags the value from a page. One

  • 0

I have a piece of jquery which drags the value from a page. One of the elements is a data attribute that is dynamically created dependent on form input. It returns the value but sticks ‘undefined’ infront of it on the first loop.

Relevent Code is as follows…

var get_files_split=get_files.split("*^*");
        var files_count=get_files_split.length-1;
        if(files_count!=0)
        {
            $('.uploaded_files').html("");
            var app_files="";
            for(var y=0;y<files_count;y++)
            {
                var files_split=get_files_split[y].split("|");
                app_files+="<div class='upfile_holder'>";
                app_files+="<div class='f_h'><span class='fil1'  data-this_file='"+files_split[0]+"'>"+files_split[1]+"</span> (<span class='fil5'>"+files_split[6]+"</span>)</div>";
                app_files+="<div class='f_h fil2'>"+files_split[2]+"</div>";
                if(files_split[4]!="")
                {
                app_files+="<div class='f_h'>&pound;<span class='fil3'>"+files_split[4]+"</span> <span class='fil4'>"+files_split[5]+"</span></div>";
                }
                if(files_split[3]!="")
                {
                    app_files+="<div class='f_notes'>";
                    app_files+="<p class='fil6'>"+files_split[3]+"</p>";
                    app_files+="</div>";
                }
                app_files+="</div>";


            }
            $(app_files).appendTo('.uploaded_files');
        }

This places the data on the page

JQuery that reselects the data is as follows…

var files_inform;
if($('.upfile_holder').length)
{
    $('.upfile_holder').each(function(){
            var file_ids=$('.fil1', this).data('this_file');
            var file_name=$('.fil1', this).text();
            var file_type=$('.fil5', this).text();
            var file_priority=$('.fil2', this).text();
            var file_price=$('.fil3', this).text();
            var file_tender=$('.fil4', this).text();
            var file_notes=$('.fil6', this).text();
            files_inform+=file_ids+"|"+file_name+"|"+file_type+"|"+file_priority+"|"+file_price+"|"+file_tender+"|"+file_notes+"*^*";
            alert(files_inform);
        });
}

The reason for reselecting the data is that the appended part is contained within a different function to when it is extracted.

Can’t figure out why it is coming up as indefined.

  • 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-11T09:21:54+00:00Added an answer on June 11, 2026 at 9:21 am

    I have found the problem:-

    var files_inform;
    

    Should be –

    var files_inform="";
    

    Just by declaring the variable seems to mean this first state is undefined whereas declaring it as an empty means that it contains nothing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of jQuery code that fills an element on the page
I have the following piece of jquery. Which basically is a content slider, that
As per title. I have a piece of jQuery that looks like the following
Here's my problem, I have a piece of jquery that works fine in modern
I have grabbed some XML data using this piece of jQuery: $.ajax({ type: POST,
I have quite a complex piece of code (JQuery and HTML5 Web SQL) that
I have a piece of jQuery code which invokes several getJSON() calls in quick
So I have a piece of jquery that is suppose to take the html
I have this piece of jQuery which is using a call back on selection.
I have this little piece of jQuery/jqModal code which works fine. However, I am

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.