Results 1 to 6 of 6

Thread: MVC: How to program this button in asp.net core C#?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    123

    MVC: How to program this button in asp.net core C#?

    MVC: How to program this button in asp.net core C#?

    HTML Code:
    <input type="text" name="FirstNumber">
    <input type="text" name="SecondNumber">
    <input type="text" name="ThirdNumber">
    HTML Code:
    <input type="button" value="submit">
    How to program submit button to show me on page onclick
    Code:
    FirstNumber * SecondNumber / ThirdNumber
    Thanks advance
    Last edited by dday9; Oct 30th, 2023 at 02:12 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,477

    Re: MVC:How to program this buttn in asp.net core C#?

    What do you mean by "give me"? Please provide a FULL and CLEAR explanation of the problem.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    123

    Re: MVC:How to program this buttn in asp.net core C#?

    I mean show me on page like on a lable

  4. #4
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,549

    Re: MVC:How to program this buttn in asp.net core C#?

    Quote Originally Posted by Max45 View Post
    I mean show me on page like on a lable
    So what have you done so far? Have you tried creating an MVC project? Have you written any code? Have you looked at any tutorials? What exactly are you having problems with?

  5. #5
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,809

    Re: MVC: How to program this button in asp.net core C#?

    You can setup a JavaScript function to do this:
    Code:
    const buttonClick = e => {
        e.preventDefault();
    
        const firstNumber = document.querySelector('input[name="FirstNumber"]').value || '0';
        const secondNumber = document.querySelector('input[name="SecondNumber"]').value || '0';
        const thirdNumber = document.querySelector('input[name="thirdNumber"]').value || '0';
        const result = firstNumber * secondNumber / thirdNumber;
        console.log(result);
    };
    window.addEventListener('load', () => document.querySelector('button').addEventListener('click', buttonClick), false);
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    123

    Re: MVC: How to program this button in asp.net core C#?

    Quote Originally Posted by dday9 View Post
    You can setup a JavaScript function to do this:
    Code:
    const buttonClick = e => {
        e.preventDefault();
    
        const firstNumber = document.querySelector('input[name="FirstNumber"]').value || '0';
        const secondNumber = document.querySelector('input[name="SecondNumber"]').value || '0';
        const thirdNumber = document.querySelector('input[name="thirdNumber"]').value || '0';
        const result = firstNumber * secondNumber / thirdNumber;
        console.log(result);
    };
    window.addEventListener('load', () => document.querySelector('button').addEventListener('click', buttonClick), false);
    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width