How do I reference javascript source code loaded with inserted script tag

I am developing a personal journaling application that will
present a web page with a form for creating journal entries.
The journal entries are submitted to PHP scripts to write a
javascript source code file. The source code file defines a
variable for the month and properties representing weekday
and day number. Further sub properties are headings that
represent predetermined text labels. Then there is or is not
text to go with that.

The php code writes the file text and returns and asyncronous
response. The response adds a script tag to the page that loads
the script file that was just written to.

The code is then supposed to read the js source file with the
[month][day] properties.

So this is an issue of getting text to reference an object variable.
How would this be done?

I have been playing with eval(). But I am getting complaints.
or not what I am expecting.

Platform:
Firefox v134.01 on Mac os Sequoia. MAMP localhost server.

Thank you for time and attention
JK

Thank you to anyone who read this post.

I believe I have figured this out. It is a matter of defining
a variable in the written js source file that can always be
reference literally. It is defined as an object and properties
can be addressed via text references.

Hi @jekillen :wave:

Thanks for submitting the topic to the MDN Discourse. Glad you’ve got the answer! :tada:

Hello @jekillen

please notice that your email is displied next to your name so from security and privacy point of view remove it

this issue should be fixed for new users based on that github page

and have a nice day everyone :slight_smile: