Building a string from an array.

0 favourites
  • 4 posts
From the Asset Store
Buildings - Isometric view - PNG transparent - multi styles, multi fonctions buildings
  • Ok, I know I'm missing something just blatantly obvious here but for the life of me, it's kicking my ass.

    I have a JS in my HTML that's calling this Get Checked Mail ID function each time a checkbox is clicked. It's passing a csv of numbers to this function with each checkbox ID. Ex - 9,3,4,2,5

    I'm splitting that csv into an array and doing a foreach.

    What I'm trying to build is a URL with an array to post with ajax, similar to this:

    example.com/api The purpose of this function is to build that URL array and save it to a string.

    What I get from this code is the first element in the csv/array (delete_emails[]=9) and none of the others.

    I know the csv looks good passed from the JS. What I can't tell because the JS won't run in debug is whether the array is getting populated correctly or my concatenation is screwed up. Which is why for now I'm just setting that EmailTitle to the string it creates.

    Thanks.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • And just as a test I set that EmailTitle to the MailDeleteArray.AsJson and it appears to be properly loading the CSV so... it must be in my concatenation.

  • Loopindex doesn't work in For Each element loops. Either use System For loop, or Array.CurValue expression.

    Actually, that's not even "For Each element" loop on your screenshot, it's "For Each instance".

  • Loopindex doesn't work in For Each element loops. Either use System For loop, or Array.CurValue expression.

    Actually, that's not even "For Each element" loop on your screenshot, it's "For Each instance".

    DOH!

    Thanks. Just used to php and throwing that array in there and expecting a foreach for each of it's elements.

    Knew I was doing something totally stupid.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)