Im new here, Im new in programming as well and I seldom code anything, but recently I've always wanted to improve my work place and I just want to create a simple form for my colleagues.
To make things short, I've created the form, what I need is just generating all the result of the form into a textarea.
Now my problem is, I've made several type of "Event" in the form that have different set of choices, and what I want is the result of that set of "Event" generated as well with the basic information.
Well, here example of my code; Begin 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";
//problem 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";
//problem 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
And if a user clicked option that have value "Lost Person", the result for generated text will be taken from event "type2"
So I've managed to get the result for name, phone, and address, but as for lost item result, the value of the result became "undefined".
So... how exactly can I code this? I am not even sure if Im really doing the right script / method for my simple form... Thanks in advance