Credit1Finance Submit Button Redirection

PHOTO EMBED

Tue Sep 26 2023 12:23:38 GMT+0000 (Coordinated Universal Time)

Saved by @nikanika4425

const {
    array_totalUnsecuredDebt,
    array_credit_score,
    array_number_of_collections,
    fname,
    lname,
    zip_code,
    address_street,
    'email-address': email,
    'phone-number': mobile,
    'loan-amount-slider': loanAmountSlider
} = feathery.getFieldValues();

// Convert loanAmountSlider to string and append '000'
const postLoanAmount = (loanAmountSlider * 1000).toString();

// First Button Conditions
if (
    array_totalUnsecuredDebt >= 25000 &&
    array_credit_score >= 540 &&
    array_number_of_collections <= 6 &&
    array_totalUnsecuredDebt !== null &&
    array_credit_score !== null &&
    array_number_of_collections !== null
) {
    console.log("Redirecting to first URL (Webflow thank-you page)");
    const thankYouURL = `https://www.credit1finance.com/survey-bot?fname=${fname}&email=${email}&phone=${mobile}&post_credit_score=${array_credit_score}&post_loan_amount=${postLoanAmount}&post_unsecured_debt=${array_totalUnsecuredDebt}`;
    location.href = thankYouURL;
}

// Second Button Conditions
else if (
    array_totalUnsecuredDebt >= 15000 &&
    array_totalUnsecuredDebt <= 24999 &&
    array_credit_score >= 540 &&
    array_number_of_collections <= 6 &&
    array_totalUnsecuredDebt !== null &&
    array_credit_score !== null &&
    array_number_of_collections !== null
) {
    console.log("Redirecting to second URL (Webflow thank-you page)");
    const thankYouURL = `https://www.credit1finance.com/survey-bot?fname=${fname}&email=${email}&phone=${mobile}&post_credit_score=${array_credit_score}&post_loan_amount=${postLoanAmount}&post_unsecured_debt=${array_totalUnsecuredDebt}`;
    location.href = thankYouURL;
}

// Third Button Conditions
else if (
    array_totalUnsecuredDebt >= 10000 &&
    array_totalUnsecuredDebt <= 14999 &&
    array_totalUnsecuredDebt !== null
) {
    console.log("Redirecting to third URL");
    location.href = "https://www.credit1finance.com/thank-you-np";
}

// Fourth Button Conditions (Default Redirection)
else {
    const redirectURL = `https://rankpro.pngtrk30.com/MfmEN?transaction_id=${Math.random().toString(36).substr(2, 9)}&first_name=${fname}&last_name=${lname}&email=${email}&mobile=${mobile}&address=${address_street}&zip_code=${zip_code}`;
    console.log("Redirecting to fourth URL");
    location.href = redirectURL;
}
content_copyCOPY