0
Dear(s) I see myself in the following situation in which I cannot imagine a solution:
We have a selection field in html containing some Brazilian states and the Federal District, when choosing an option, it would lead me to open another type of choice a radio button, between Capital and Interior being each capital and the option of interior with their respective values, where I would take this value of the given capital or the interior and lead to make an account by multiplying a value of another radio button equivalent to the daily ones so show this value in a text field.
Exemplo
Numero de diárias: ()Uma diária (x)Duas diárias ()Três diárias
Selecione o estado: Select SP\/
//Apareceria outro radio button:
(x)São Paulo () Interior
In the case of São Paulo the value would be R$200.00 times daily
then the textfield with the help of javascript would be:
Value = 400,00
<select name="estado" id="estado" >
<option name="nenhum" value=""> Escolher </option>
<option name="DF" value="DF"> Distrito Federal </option>
<option name="SP" value="SP"> São Paulo </option>
<option name="outros" value="Outros"> Outros Estados
</option>
//It opens multiple choice of two options if the user chose the Federal District, then
<input required="required" value="Brasília" name="capital" type="radio">
<label for="capital">Brasília</label> <input required="required" value="Interior" name="capital" type="radio"><label for="capital">Interior</label>
//Note that depending on the field select the valor
and the label
radio button would change.
//Soon the daily rate for Brasilia has value of 250.30 and the interior is fixed for all states 160.00.
At that point I would need to do the I imagine account with IFs
for each capital and multiply with the value of the daily radio button element up there.
That was the way I thought. Was there any way I could do that or any other way that I could get the same result? That is to have the name of the capital to be able to write in the database, and the value of the capital to make the account with the daily ones. How could I do this in Json or Javascript?
I didn’t understand if you want to have all states and prices in the database? Want to use
javascript
to enter into the database?– Jorge B.
No, I want to have all the names of states and names of capitals, I want to use javascript to change the variable capital to the capital according to the state. Ex: SP -> São Paulo, RJ -> Rio de Janeiro, AC -> Rio Branco
– Vinicius