Use drop down to add text to existing sentence in text box
I recently used Thom Parker's "Changing another field with combo box (drop down) selection" article (Thanks Thom!) to make a form that has two text boxes and one drop down. Depending on what you select in the drop down, the two text boxes are populated with unique sentences. What I would like to do is have an additional drop down that contains a word or number selection that when chosen would place it into one of the sentences. For my form, I have a drop down that you select why you are advising someone, which populates the 'Reason for Advising' text field with a small explanation and also populates 'Plan of Action' with a short summary of what we intend to do. Right now I have created an underlined section in the sentence where the user can simply type additional information, but I would like to have a second drop down that they could choose from to populate that area of the sentence. So looking at Thom's original document script:
// Place all pre-population data into a single data structure
var DeptData = { Accounting:{ contact: "Steala Damuni", email: "accounting@mycomp.com", deptnum: "cmp1234" }, Engineering:{ contact: "Frank N. Stien", email: "engineering@mycomp.com", deptnum: "eng1234" }, Marketing :{ contact: "Shelly Oughtbuks", email: "marketing@mycomp.com", deptnum: "mkt1234" }, ITSupport:{ contact: "Goah Wei", email: "it@mycomp.com", deptnum: "its1234" }};
function SetFieldValues(cDeptName) {
// Populate fields with values from the Department Data Object
this.getField("DeptContact").value = DeptData[cDeptName].contact;
this.getField("DeptEmail").value = DeptData[cDeptName].email;
this.getField("DeptNumber").value = DeptData[cDeptName].deptnum;
}
So for example, what changes could be made so that the email domain in the above script would be filled based on the results of a second drop down? I am nowhere near an expert on this, and I have done well just to get by tweaking other peoples scripts. I assume I can create another variable, I just don't know how to place it in the middle of the sentence. Thanks for any help or suggestions.
Mike
