Hope this will help you.  Mark Best ANSWER if its works for you.  Thanks karthik  ", "upvoteCount": 2, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T4WMvSAN", "datePublished": "2016-10-11T07:06:43.000Z", "author": { "@type": "Person", "name": "karthikeyan perumal", "url": "https://trailblazers.salesforce.com/profileView?u=0053000000BgCy3AAF", "affiliation": { "@type": "Organization", "name": "TEKsystems" } } }, "suggestedAnswer": [] } }
Skip to main content
I am creating Web-to-Lead HTML, and the website captures the first AND last names in a "Name" field. 

Salesforce wants 'First Name' and 'Last Name' as separate fields. I may not be able to talk them into changing the website form to capture these fields separately. 

What's the best way to deal with this? I could create a custom "Name" field on the Lead object and capture this field, but then how would I best break this up into 'First Name' and 'Last Name'
4 answers
  1. Oct 11, 2016, 7:06 AM
    Hello, 

    use below code with javasscript.. i will take full Name and split it in to first name and last name send to salesfroce. 

    Type hidden for Frst name and last name. add new text called name like below. add the onchange event. use the javascript function. 

     

    <META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">

    <script>

    function TextCapture(txtid)

    {

    var OriginalValue=document.getElementById("name").value;

    alert(OriginalValue);

    document.getElementById("first_name").value=OriginalValue.substr(0,OriginalValue.indexOf(' '));

    document.getElementById("last_name").value=OriginalValue.substr(OriginalValue.indexOf(' ')+1);;

    }

    </script>

    <form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

    <input type=hidden name="oid" value="00D28000000fJRI">

    <input type=hidden name="retURL" value="http://">

    <label for="name">Name</label><input id="name" maxlength="80" name="name" size="20" onchange="TextCapture(this)" type="text" /><br>

    <input type="hidden" id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

    <input type="hidden" id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

    <label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>

    <label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>

    <label for="city">City</label><input id="city" maxlength="40" name="city" size="20" type="text" /><br>

    <label for="state">State/Province</label><input id="state" maxlength="20" name="state" size="20" type="text" /><br>

    <input type="submit" name="submit">

    </form>

    Hope this will help you. 

    Mark Best ANSWER if its works for you. 

    Thanks

    karthik

     
0/9000