Hello everyone, I am a newcomer to this community and also to the world of programming. Despite my limited experience with coding, I have been eager to enhance my workplace by creating a basic form for my colleagues.
In summary, I have successfully created the form, but I am now facing the challenge of generating all the form results into a textarea.
The issue lies in the fact that my form includes various types of "Event" with distinct sets of choices, and I aim to have the results of each "Event" set generated alongside the basic information.
Here is an excerpt of my code; Beginning of Javascript
function generateresult() {
name = document.FORM.namefromtextarea.value;
phone = document.FORM.phonefromtextarea.value;
address = document.FORM.addressfromtextarea.value;
name2 = "Name: " + name + "\n";
phone2 = "Phone: " + phone + "\n";
address2 = "Address: " + address + "\n";
//Issue type 1
lostitem = document.FORM.lostitemfromtextarea.value;
when = document.FORM.whenfromtextarea.value;
where = document.FORM.wherefromtextarea.value;
lostitem2 = "Lost Item?: " + lostitem + "\n";
when2 = "When?: " + when + "\n";
where2 = "Where?: " + where + "\n";
//Issue type 2
lostperson = document.FORM.lostpersonfromtextarea.value;
personage = document.FORM.personagefromtextarea.value;
personcloth = document.FORM.personclothfromtextarea.value;
lostperson2 = "Person Name?: " + lostperson + "\n";
personage2 = "Age?: " + personage + "\n";
personcloth2 = "Wearing?: " + personcloth + "\n";
if (document.FORM.problemtype.value="Lost Item")
{
eventtype = type1;
}
else if (document.FORM.problemtype.value="Lost Person")
{
eventtype = type2;
}
type1 = lostitem2 + when2 + where2 ;
type2 = lostperson2 + personage2 + personcloth2 ;
document.FORM.generateresulttext.value = name2 + phone2 + address2 + eventtype ;}
End of javascript
If a user selects an option with the value "Lost Person", the generated text result will be derived from event "type2"
While I have successfully obtained the results for name, phone, and address, the issue arises with the lost item result, which for some reason displays as "undefined".
Thus, I am uncertain about the accuracy of my script/method for this simple form. Any guidance on how to resolve this issue would be greatly appreciated. Thank you in advance.