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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:54:24+00:00 2026-06-02T19:54:24+00:00

i have this array in my lua… local data = {} data[1] = {}

  • 0

i have this array in my lua…

local data = {}

data[1] = {}
data[1].title = "Crazy Song"
data[1].subtitle = "by Bruno Earth"
data[1].image = "note.png"

data[2] = {}
data[2].title = "Enter Sunman"
data[2].subtitle = "by Mentalica"
data[2].image = "note.png"

data[3] = {}
data[3].title = "Bitter Child of Mine"
data[3].subtitle = "by Gunz n bullets"
data[3].image = "note.png"

data[4] = {}
data[4].title = "Missed A thing"
data[4].subtitle = "by Ero-Smith"
data[4].image = "note.png"

data[5] = {}
data[5].title = "Pornstar"
data[5].subtitle = "by Nicklefront"
data[5].image = "note.png"

data[6] = {}
data[6].title = "Burner"
data[6].subtitle = "by Asher"
data[6].image = "note.png"

how can i get the array values by not using id on it. i just want to get the title for my conditional statement?

i try this in my code:

local getTitle = function(event)
    print (".................")
    print (event.target.id)
    print (event.target.title)
end

but i got only this…

touch: began
touch: ended
.................
2
nil

how can i get and print the title of my array?

this is my code:

module(..., package.seeall)
display.setStatusBar( display.HiddenStatusBar ) 
function new()
    local localGroup = display.newGroup()
    local tableView = require("tableView")
    local ui = require("ui")

    --------------------------------------------------------------------------
    local screenOffsetW, screenOffsetH = display.contentWidth -  display.viewableContentWidth, display.contentHeight - display.viewableContentHeight

    local songList
    local backBtn
    local detailScreenText

    local background = display.newRect(0, 0, display.contentWidth, display.contentHeight)
    background:setFillColor(0, 0, 0)
    localGroup:insert(background)

    local data = {}
    --iPad: setup a color fill for selected items
    local selected = display.newRect(0, 0, 50, 50)  --add acolor fill to show the selected item
    selected:setFillColor(67,141,241,180)  --set the color fill to light blue
    selected.isVisible = false  --hide color fill until neede

    -----------------------------------------------
    data[1] = {}
    data[1].title = "Crazy Song"
    data[1].subtitle = "by Bruno Earth"
    data[1].image = "note.png"

    data[2] = {}
    data[2].title = "Enter Sunman"
    data[2].subtitle = "by Mentalica"
    data[2].image = "note.png"

    data[3] = {}
    data[3].title = "Bitter Child of Mine"
    data[3].subtitle = "by Gunz n bullets"
    data[3].image = "note.png"

    data[4] = {}
    data[4].title = "Missed A thing"
    data[4].subtitle = "by Ero-Smith"
    data[4].image = "note.png"

    data[5] = {}
    data[5].title = "Pornstar"
    data[5].subtitle = "by Nicklefront"
    data[5].image = "note.png"

    data[6] = {}
    data[6].title = "Burner"
    data[6].subtitle = "by Asher"
    data[6].image = "note.png"

    local topBoundary = display.screenOriginY + 40
    local bottomBoundary = display.screenOriginY + 0

    local getTitle = function(event)
        print (".................")
        print (event.target.id)
        print (event.target.title)
    end

    songList = tableView.newList{
        data=data,
        default="listItemBg.png",
        over="listItemBg_over.png",
        onRelease=getTitle,
        top=topBoundary,
        bottom=bottomBoundary,
        callback = function( row )
            local g = display.newGroup()

            local img = display.newImage(row.image)
            g:insert(img)
            img.x = math.floor(img.width*0.5 + 6)
            img.y = math.floor(img.height*0.5)

            local title =  display.newText( row.title, 0, 0, native.systemFontBold, 16 )
            title:setTextColor(0,0,0)
            g:insert(title)
            title.x = title.width*0.5 + img.width + 6
            title.y = 30

            local subtitle =  display.newText( row.subtitle, 0, 0, native.systemFont, 14 )
            subtitle:setTextColor(80,80,90)
            g:insert(subtitle)
            subtitle.x = subtitle.width*0.5 + img.width + 6
            subtitle.y = title.y + title.height + 6

            return g
        end
     }
    localGroup:insert(songList)
    local function scrollToTop()
        songList:scrollTo(topBoundary-1)
    end

    local navBar = display.newImage("navBar.png")

    navBar.x = display.contentWidth*.5
    navBar.y = math.floor(display.screenOriginY + navBar.height*0.5)
    localGroup:insert(navBar)

    local navHeader = display.newText("Song Lists", 0, 0, native.systemFontBold, 16)
    navHeader:setTextColor(255, 255, 255)
    navHeader.x = display.contentWidth*.5
    navHeader.y = navBar.y
    localGroup:insert(navHeader)

    --backBtn.alpha = 0

    local listBackground = display.newRect( 0, 0, songList.width, songList.height )
    listBackground:setFillColor(255,255,255)
    songList:insert(1,listBackground)

    --Setup the back button
    function changeScene(e)
        if e.phase == 'ended' then
            print ("ok")
            director:changeScene(e.target.scene, "fade")
            print ("back!")

        end
    end

    backBtn = display.newImage("backButton.png")
    backBtn.x = math.floor(backBtn.width/2) + backBtn.width + screenOffsetW
    backBtn.y = navBar.y 
    backBtn.scene = "menu"
    backBtn:addEventListener("touch", changeScene)

    return localGroup
end
  • 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-02T19:54:29+00:00Added an answer on June 2, 2026 at 7:54 pm

    i got it…
    i do this

    local getTitle = function(event)
        print (".................")
        local id = event.target.id
        print (id)
        print (data[id].title)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this array Array ( [data] => Array ( [0] => Array (
I have this array Array ( [0] => posts Object ( [title] => test1
I have this array: unsigned char* data = CGBitmapContextGetData(cgctx); then I tried to get
i have this array char ***three_dim=0; three_dim is allocated and populated with data. After
I have this array in PHP: array( [0] => array( 'username' => 'user1' )
I have this array, for example (the size is variable): x = [1.111, 1.122,
I have this array: string[,] productData = new string[5,7]; I bind it to a
I have this array: $items_pool = Array ( [0] => Array ( [id] =>
I have this array: $methodsOutput = array(MidUpperArmMuscleArea,ArmSpan_HeightEstimation,BMIBeforePregnancy, PregnancyTotalWeightGain,PregnancyWeeklyWeightGain,MS_CurrentBMI_BMIPregnancyWeeks, PregnancyDueDate,PregnancyWeeks,WeightEstimation,WHO_BMI_2000_IdealBMI, WHO_BMI_2000_IdealWeight,WHO_HeightAge_2006_IdealHeight,WHO_WeightAge_2006_IdealWeight); and for each one
I have this array $test = $_POST['test']; print_r($test); Array ( [0] => Array (

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.