var form = document.createElement("form");
form.setAttribute("method", "post");
// Create input fields
var fields = ["First Name", "Last Name", "Company Name", "Work Email", "Contact Number", "Mode of Shipment", "Countries You Ship", "Monthly Shipment", "Customer Type", "Where Did You Hear About Us"];
fields.forEach(function(field) {
var input = document.createElement("input");
input.setAttribute("type", "text");
input.setAttribute("name", field.toLowerCase().replace(/ /g, "_"));
input.setAttribute("placeholder", field);
form.appendChild(input);
});
// Create checkbox
var checkbox = document.createElement("input");
checkbox.setAttribute("type", "checkbox");
checkbox.setAttribute("name", "agree_to_terms");
var label = document.createElement("label");
label.innerHTML = "I agree to the Zindus terms of use and acknowledge its privacy statements";
form.appendChild(checkbox);
form.appendChild(label);
// Create signup button
var button = document.createElement("button");
button.setAttribute("type", "submit");
button.innerHTML = "Sign Up";
form.appendChild(button);
// Append form to body
document.body.appendChild(form);
// Add event listener for form submission
form.addEventListener("submit", async function(event) {
event.preventDefault();
// Get form data
var formData = new FormData(form);
// Convert form data to JSON
var jsonData = {
"data": [{
"First_Name":"Jhon1",
"Last_Name": "clarke",
"company_name": "ABC Company",
"contact_number": 123456789,
"mode_of_shipment": "Air",
"countries_you_ship": "United States",
"monthly_shipment": "100",
"customer_type": "New Customer",
"where_did_you_hear": "Online Advertisement",
"agree_to_terms": true}],
"trigger": ["approval", "workflow", "blueprint"]
};
// Make API request to Zoho CRM Contacts module
method: "POST",
headers: {
"Authorization": "Bearer access_token",
"Content-Type": "application/json",
},
body: JSON.stringify(jsonData),
}).then(function(response) {
return response.json();
}).then(function(data) {
console.log(data);
}).catch(function(error) {
console.error(error);
});
});