In a customer Zendesk form, set subject field to the values of dropdown fields

33 Views Asked by At

I've been working on this for hours with little success. Using jQuery, I want to set the subject field to concatenate the values of 2 other dropdown fields. In script.js, I have something like this going. When this dropdown field is updated, it runs through the if conditions to set the reasonforcontact variable, and then set the subject to equal that variable. That works so far. I want to do the same sort of thing with a different dropdown field, set a different variable, and then use the 2 variables to set the subject.

$('#request_custom_fields_20094966253837').change(function(){
 
if ($(this).attr('value') == 'customer_placing_an_order') {
let reasonforcontact = "Placing an Order";
$('#request_subject').val(reasonforcontact);
}
    
if ($(this).attr('value') == 'customer_website_issues') {
let reasonforcontact = "Website Issues";
$('#request_subject').val(reasonforcontact);
}
});

I'm not sure if I need to call different functions or something else. I've tried referring to the other dropdown field value by adding this into the same function, but it doesn't work:

if ($('#request_custom_fields_20094966253837').attr('value') == 'orgproduct_collegeitem') {
let orgproduct = "College Item";
$('#request_subject').val(orgproduct);
}

0

There are 0 best solutions below