Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
How to pass First Second and Last name to alert in onClick event?

Well my code is pretty simple, yet i don't know how to pass the names to alert first, if i figure this out, i might be able to pass them to backend(probably)..

html:

<div class="container">
  <h1>Update Account Info</h1>
  <form>
    <label for="firstName">First Name </label>
    <div class="form-group">
      <input type="text" class="form-control" id="firstName">
    </div>
    <label for="secondName">Second Name </label>
    <div class="form-group">
      <input type="text" class="form-control" id="secondName">
    </div>
    <label for="lastName">Last Name </label>
    <div class="form-group">
      <input type="text" class="form-control" id="lastName">
    </div>
    <button (click)="onClick($event)" class="update-btn" id="update-btn">Update</button>
   </form>
 </div>

ts:

import { IdToken } from '@azure/msal-common';
@Component({
  selector: 'edit-profile',
  templateUrl: './edit-profile.component.html',
  styleUrls: ['./edit-profile.component.scss']
})
export class EditProfileComponent implements OnInit {
  constructor() { }
  ngOnInit() {

  }
  onClick(){

}
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For reactive form check this link "https://www.tektutorialshub.com/angular/angular-reactive-forms/"

OR Check Below code

HTML Code

<div class="container">
  <h1>Update Account Info</h1>
  <form>
    <label for="firstName">First Name </label>
    <div class="form-group">
      <input type="text" class="form-control" id="firstName" [(ngModel)]="formData.firstName">
    </div>
    <label for="secondName">Second Name </label>
    <div class="form-group">
      <input type="text" class="form-control" id="secondName" [(ngModel)]="formData.secondName">
    </div>
    <label for="lastName">Last Name </label>
    <div class="form-group">
      <input type="text" class="form-control" id="lastName" [(ngModel)]="formData.lastName">
    </div>
    <button (click)="onClick()" class="update-btn" id="update-btn">Update</button>
   </form>
 </div>

TS File Code

export class EditProfileComponent implements OnInit {
    public formData = {
        firstName:'',
        secondName:'',
        lastName:'',
      }
    
    constructor() { }
      ngOnInit() {}
      onClick(){
          console.log(this.formData);
      }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!