Ok Hi everyone - it is late after 2am and my brain...
# cfml-general
g
Ok Hi everyone - it is late after 2am and my brain has stopped. I have a struct that I have created with
Copy code
answerStr = {
    "Value" = "Value-1",
    "Description" = "Description-1"
};
questionsStruct["Q1"] = answerStr;
answerStr = {
    "Value" = "Value-2",
    "Description" = "Description-2"
};
questionsStruct["Q2"] = answerStr;
Now I want the following outcome in my table
Copy code
<tr>
<td>Q1</td>
<td>Value-1</td>
<td>Description-1</td>
</tr>
<tr>
<td>Q2</td>
<td>Value-2</td>
<td>Description-2</td>
</tr>
I have tried with the following (and so many other flavours.... DOT notaion Square Brackets without DOTS / with DOTS / with Quotes / without Quotes... I just can't seem to get it to output the actual contents of the structs I can get the contents of the TD cell to look like the string literal;
aQuestion.Q1.Value
- but not what it should evaluate to.... I tried wrapping the contents in
DE()
, I tried
saveContent()
....
Copy code
i=0;
cfloop(collection=questionsStruct item="aQuestion"){
    i++;
    writeOutput('
        <tr>
            <td>Q#i#</td>
            <td>aQuestion.Q#i#.#Value#</td>
            <td>Q#i#.Description</td>
         </tr>
    ');
}
Anyway - if someone wouldn't mind helping me out - I'd really appreciate it!
z
mate, you posted this in #lucee, before please don't post the same question in more than one place
anyone wanting to help, dive into the original thread here https://cfml.slack.com/archives/C06TA0A9W/p1654155572570409
s
Deleted Sathish's response for not doing what Zac asked and answering it in the original thread!
👍 1
s
I didn't notice Zack's answer, Thanks @seancorfield
👍🏻 1
👍 1
a
Steady on fellas (@zackster / @seancorfield). It's not the same question.
s
It's a continuation of the long thread in #lucee and asking it here loses all the context of that thread. @gavinbaumanis had already engaged people there to help. I suspect with it being "2am and [his] brain has stopped" he posted it here by accident.
g
Hey there - new day.... Sorry about writing this in a different channel.. It wasn't deliberate. At the time of writing it, my brain really had given up on working... it took me nearly 30 minutes to write and format... typing the same line twice / deleting the wrong thing when I found an error (pressing ENTER and saving it - then having to delete the post and try again)... I think the lesson is : don't work when you know your passed it... - or better yet; Just don't work.... I should have stayed retired!!! 😀 I do see that @Matt Jones got my loop working... which is greatly appreciated... It's like the fairys did my work for me, while sleeping! Thanks again to everyone!