-
Oct 30th, 2023, 12:32 AM
#1
Thread Starter
Lively Member
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.
-
Oct 30th, 2023, 01:38 AM
#2
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.
-
Oct 30th, 2023, 01:50 AM
#3
Thread Starter
Lively Member
Re: MVC:How to program this buttn in asp.net core C#?
I mean show me on page like on a lable
-
Oct 30th, 2023, 03:53 AM
#4
Re: MVC:How to program this buttn in asp.net core C#?
Originally Posted by Max45
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?
-
Oct 30th, 2023, 02:14 PM
#5
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);
-
Oct 30th, 2023, 11:13 PM
#6
Thread Starter
Lively Member
Re: MVC: How to program this button in asp.net core C#?
Originally Posted by dday9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|