As @cigano said the solution of this problem may be better in Javascript.
Follow example using HTML + Javascript with Jquery and the JSFIDDLE working
HTML:
<form>
<fieldset>
<legend>Grupo 1 (Primeiro Dígito):</legend>
<input type="radio" name="grupo1" value="1"/> 1<br/>
<input type="radio" name="grupo1" value="2"/> 2<br/>
<input type="radio" name="grupo1" value="3"/> 3<br/>
</fieldset>
<fieldset>
<legend>Grupo 2 (Segundo dígito):</legend>
<input type="radio" name="grupo2" value="1"/> 1<br/>
<input type="radio" name="grupo2" value="2"/> 2<br/>
<input type="radio" name="grupo2" value="3"/> 3<br/>
</fieldset>
<fieldset>
<legend>Grupo 3 (Potencia):</legend>
<input type="radio" name="grupo3" value="1"/> 2<br/>
<input type="radio" name="grupo3" value="2"/> 3<br/>
<input type="radio" name="grupo3" value="3"/> 3<br/>
</fieldset>
Resultado:
<input type="text" id="txtResultado"/>
</form>
Javascript:
$(document).ready(function(){
$('input:radio').on('click',CalculaResultado);
});
function CalculaResultado(oRadio){
var grupo1 = $('input:radio[name="grupo1"]:checked').val();
var grupo2 = $('input:radio[name="grupo2"]:checked').val();
var grupo3 = $('input:radio[name="grupo3"]:checked').val();
var resultado = parseInt(grupo1.toString() + grupo2.toString())
resultado = Math.pow(resultado,parseInt(grupo3))
if (!isNaN(resultado))
$('#txtResultado').val(resultado);
else
$('#txtResultado').val(0);
}
You want in Razor?
– Leonel Sanches da Silva
I’m a little young in c# and I don’t know Razor. I edited the question title. But the case is that I need to concatenate two values one of each raddiobutton and raise the power of a raddiobutton value of the ultima groupbox. However each raddiobutton must contain a value for example. Raddiobutton1 has to store the value 10; so I can’t do it with just true or false; I don’t know if I can express myself correctly.
– Rech
This can be solved by [tag:javascript]. I edited your question to reach the appropriate audience.
– Leonel Sanches da Silva
Thank you very much! I’ll start formatting the text the same way you did. I’m sorry I’m inexperienced at stackoverflow.
– Rech
@gypsy the question refers to c# same and not html and javascript.
– Rech
Actually the focus of the question is not on [tag:c#]. Predominantly the calculation you need is a client behavior, solvable by [tag:javascript]. C# may end up coming in later, but not now.
– Leonel Sanches da Silva
I will try to explain what I am trying to do. It is a small program to calculate the value of the electronic component resistor. Each resistor has a different resistance value and its value is indicated by a color code as well as its tolerance. a
groupbox1
represents the first colour range of the resistor togroupbox2
represents the second colour band and thegroupbox3
represents your multiplier I created a form and inserted these components the case is I would like to know the best syntax to solve this I got lost because in php would be very easy for me to do.– Rech
So, as I told you and will repeat: the behavior of
RadioGroups
shall be calculated as a screen. To send the final result pro Controller (in the case of a MVC application), these values must first be calculated on screen.– Leonel Sanches da Silva
It’s really just one
form
even could be something very simple and not a MVC application, but now I understood what you meant.– Rech