function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mohit S.Mohit S. 

Saving Contact information captured using html text box into the salesforce

I have a simple VF page with some html input fields. Please help me with how can I pass the information from these html input fields to the salesforce and save in Salesforce Contact object, without redirecting away.
VF & Apex code given below is what I was trying with no success. The code is not complete & correct at all, its just few relevant yet non woking pieces I put together. Kindly help and feel free to share any code, which solves the purpose.

VF PAGE (Page Name - CSAManageProfile)
<apex:page showHeader="false" sidebar="false" standardStylesheets="false" applyHtmlTag="false" docType="html" controller="G_ManageUserViewController">

<apex:form >

<input id="txtFirstName" type="text"  class="form-control" value="{!cont.firstname}"> </input>
<input id="txtMiddleName"  type="text" class="form-control placeholder-field" Placeholder="Middle Name"/>
<input id="txtLastName" type="text"  class="form-control" value="{!cont.lastname}"> </input>

<button id="btnSaveProfile" type="button" class="btn btn-blue" value="Submit" onClick="saveProfile()">Save</button>

<script>  
function saveProfile(){
                                
    var fname = document.getElementById("txtFirstName").value;
    var mname = document.getElementById("txtMiddleName").value;
    var lname = document.getElementById("txtLastName").value;
   
}         
</script>
</apex:form >
APEX CODE (Class Name - G_ManageUserViewController)
 
public class G_ManageUserViewController {
    
    Public Contact cont{get;set;}
    Public boolean EditProfile{get;set;}
    Public boolean EditContact{get;set;}
    Public boolean isOpen {get;set;}
    public String strPageId {get;set;}
    
    public G_ManageUserViewController(ApexPages.StandardController stdController) {

    cont = (Contact) stdController.getRecord();
    }
    /*
    public Contact getMyContact() {
        //User[] users = [SELECT ContactId FROM User WHERE Id = :UserInfo.getUserId()];
        //User usr = users[0];
        //Contact[] contacts = [SELECT Name, Firstname, Lastname, Email, Phone, MobilePhone, OtherPhone, Contact_Preference__c, Communication_Preferences__c, Contact_Time_Zone__c, Work_Schedule__c, Start_Time__c, Stop_Time__c  FROM Contact WHERE Id = :usr.ContactId];
        strPageId=ApexPages.currentPage().getParameters().get('parent_id');
        Contact[] cont = [Select Id, Name,LastName,FirstName,Title, User_ID__c, User_Status__c,Email,Phone from Contact where Id=:ApexPages.currentPage().getParameters().get('Id')];    
            if (cont.isEmpty()) {
            return Null;
            // handle when contacts is empty
            } else {
                Contact MyContact = cont[0];

            return MyContact;       
        }
    }
    
    public pagereference ProfileEdit(){
        EditProfile = true;
        return null;
   }
   
   public PageReference saveContact() {
        try {
            Database.DMLOptions dmlOpts = new Database.DMLOptions();
            dmlOpts.assignmentRuleHeader.useDefaultRule = true;
            cont.setOptions(dmlOpts);
            upsert(cont);
            
        } catch (System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }

        PageReference p = new PageReference('/'+strPageId);
        p.setRedirect(true);
        return p;
    }
   */
}