-2

I have the button on a form below. * I know that making type = "button" prevents the button from submitting, but how do I still retrieve the value of the button if it's clicked?

The goal is that the user syncs their linkedin data. It also records that the button was clicked. I do not want the form to submit because I have another button that asks the user to sync their facebook data next.

<div class="center">
    <button 
        class="btn btn-linkedin btn-lg"
        data-bind="click: linkedinLogin"
        name = "linkedin"
        value = "linkedin_Submitted"
        type = "button"
        >                   
        <i class="fa fa-linkedin fa-fw"></i> 
        <span>Sync linkedin</span>
    </button>
</div>
Christoph
  • 50,121
  • 21
  • 99
  • 128
user3314418
  • 2,903
  • 9
  • 33
  • 55

2 Answers2

1

If you want to send information to a server (where I would imagine you are storing this information somewhere on a database), and you don't want to submit the entire page, you can use an event handler, and submit the data through AJAX.

An event handler would capture what action has been completed (click, keypress, hover, etc), and return some value. The discussion on this page might be informative to the capturing of event handlers.

Once you have it, you can make an AJAX call (Learn about it here). The information can be stored by whatever function you use to interface with your storage method.

Community
  • 1
  • 1
Aaron Morefield
  • 952
  • 10
  • 18
1

This has nothing to do with css, but you need javascript for this. Bind an eventhandler to your button and call the javascript function to synchronize the linkedin data (e.g. via an ajax call).

var linkedinSyncButton = document.querySelector(".btn-linkedin");

linkedinSyncButton.addEventListener("click",()=>syncLinkedin());

function syncLinkedin(){
    // sync the linkedin data
}
Christoph
  • 50,121
  • 21
  • 99
  • 128