mirror of
https://github.com/frappe/erpnext.git
synced 2025-12-03 18:35:36 +00:00
Page:
Adding Custom Form to Website
Pages
"Expense or Difference account is mandatory for [YOUR ITEM HERE] as it impacts overall stock value"
Adding Custom Form to Website
Agri Farm ERPNext
Agri Farm ERPNext Documentation
Agri Farm ERPNext Proposed Doc
Agri farm ERPNext PR git primer
AgriNext Mockups
Apache HTTP Settings for Mac OS
Bank Transaction Management : Feature Specification (v0.1)
Cascading Pull Requests
Code Editing Tools
Code Security Guidelines
Coding Standards
Community Contributions
Community Developed Custom Scripts
Community Release Manager
Contribution Guidelines
Contribution Issues
Country wise Chart of Accounts
Create User Stories
Delivery Note Modern Legacy Print Format
Delivery Note Spartan Legacy Print Format
Designing Integrations
Documentation To Do
E Commerce Features List
ERPNext Performance Tuning
ERPNext Release Note v8.1
ERPNext Upgrade to Version 5
ERPNext Version 8
ERPNext for Import Export Business( Logistics Module)
ERPNext for Non Profits
Export Custom field using export fixtures
Feature Suggestions
Form Design Guidelines
Future Development: Tracking Productivity
Guide to splitting modules from ERPNext
Home
How To Make Regional Contributions
How to Install ERPNext Version 3
How to contribute ERPNext documentation[WIP]
How to test a Pull Request
Hub Code Sprint
Improve Precision of Stock Valuation
Install ERPNext on Debian based systems
Install ERPNext on RedHat based systems
Integrating Emails in ERPNext
Issue Guidelines
Legacy Print Formats (Category)
Manufacturing Module Community
Migrating your erpnext instance to wsgi
Migration Guide To ERPNext Version 16
Migration Guide to ERPNext version 14
Migration Guide to ERPNext version 15
Model Design Guidelines
Module Maintainers
MySQL configuration file
Naming Guidelines
Page format for ERPNext docs
Preparing a Contribution Proposal
Project Module Community
Pull Request Checklist
Purchase Order Classic Legacy Print Format
Purchase Order Modern Legacy Print Format
Purchase Order Spartan Legacy Print Format
Quotation Classic Legacy Print Format
Quotation Modern Legacy Print Format
Quotation Spartan Legacy Print Format
Restoring From ERPNext Backup
Sales Invoice Classic Legacy Print Format
Sales Invoice Modern Legacy Print Format
Sales Invoice Spartan Legacy Print Format
Sales Order Classic Legacy Print Format
Sales Order Modern Legacy Print Format
Setting up Backup Manager
Setting up TLS SSL certificates Let's Encrypt for ERPNext sites
Some Useful Aliases
Standard Print Header Code
Standard Release Test Plan
Standard With Columns Print Format
Supported Versions
Test Checklists
Troubleshooting Guide Template
Ubuntu HA Cluster with lsyncd, remote MariaDB, Apache Reverse Proxy Setup Guide
Updating ERPNext Instance
VSCode Debugging for Frappe Python
Version 4 Permission Use Cases
Version 5 Release Notes
Version 7 Release Notes
Version 7.1 Release Notes
WSGI Production Deployment
[Specifications] Hash chaining of sales and payment transactions in ERPNext
_sidebar
school
Clone
2
Adding Custom Form to Website
rmehta edited this page 2013-02-26 22:08:12 -08:00
Table of Contents
To add a custom form to the website, you can create the form in HTML and then use the erpnext.send_message function via javascript to create a new Lead (or update existing one).
Example
HTML (Content)
In the Content, click on HTML to compose a form:
<div class="help">Your Company Name</div>
<input name="company_name" type="text" placeholder="My Company" /> <br /><br />
<div class="help">Your Name</div>
<input name="sender_name" type="text" placeholder="Jane Doe" /> <br /><br />
<div class="help">Your Email</div>
<input name="email" type="text" placeholder="jane_doe@example.com" /> <br /><br />
<div class="help">Your Phone Number</div>
<input name="phone" type="text" placeholder="12345676" /> <br /><br />
<div class="help">Which Product are you interested in?</div>
<select name="product">
<option value="Product 1">Product 1</option>
<option value="Product 2">Product 2</option>
<option value="Product 3">Product 3</option>
</select>
<br /><br />
<div id="form-alert" class="alert" style="display: none; margin-bottom: 10px;"></div>
<button class="btn btn-success btn-request">Send Inquiry</button><br />
Script (JS)
$(document).ready(function() {
// button for sign-up event
$('.btn-request').click(function() {
// hide any message
$("#form-alert").toggle(false);
var args = {
sender_name: $('[name="sender_name"]').val(),
company_name: $('[name="company_name"]').val(),
email: $('[name="email"]').val(),
phone: $('[name="phone"]').val(),
product: $('[name="product"]').val(),
}
// all mandatory
if(!(args.sender_name && args.company_name && args.email
&& args.phone)) {
msgprint("All fields are necessary. Please try again.");
return;
}
// email is valid
if(!valid_email(args.email)) {
msgprint('Please enter a valid email id');
return;
}
// compose the message
var message = "Company: " + args.company_name + "\n"
+ "Name: " + args.sender_name + "\n"
+ "Email: " + args.email + "\n"
+ "Phone: " + args.phone + "\n"
+ "Product: " + args.product
erpnext.send_message({
subject:'New Website Query',
sender: $('[name="email"]').val(),
status: 'Open',
message: message,
callback: function(r) {
// print return message
msgprint(r.message);
// clear all inputs
$(':input').val('');
}
});
});
});
var msgprint = function(txt) {
$("#form-alert").html(txt).toggle(true);
}