RETURN VALUE TYPED WITH JAVASCRIPT

Asked

Viewed 32 times

-2

Hello, I needed a help. The idea in Javascript is as follows... The user type a value in a input, and the application returns the value corresponding to this type value, which has already been predefined before with constant example:

var '8' = 65.60
var '101' = 189
var '17' = 126

When the user type 8, the application returns 65.60, when the user type 101, the application returns 189, and so on, someone knows how to do something like this?

Thank you for your attention.

2 answers

-1


I believe it’s something like :

var valorDigitado= document.getElementById(Id do campo do Input);

if(valorDigitado.value == 8){

var valor = 65.60;

}
  • Hello, thank you for your attention

-1

You must be asking about Switch, which is compared to each clause and if the clause is matched, the value of its variable is equal to a case, it returns a predetermined value.

To illustrate it better:

switch (expressão) {
  case valor1:
    //Instruções executadas quando o resultado da expressão for igual á valor1
    [break;]
  case valor2:
    //Instruções executadas quando o resultado da expressão for igual á valor2
    [break;]
  ...
  case valueN:
    //Instruções executadas quando o resultado da expressão for igual á valorN
    [break;]
  default:
    //Instruções executadas quando o valor da expressão é diferente de todos os cases
    [break;]
}
  • Hello, thank you so much for your friend help, very grateful.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.