-1
I have a form where for each type of expense there will be a limit value to be sent by the user. What I am using in my form is the type of the expense (being an option), the amount of the expense to be sent by the user (being a number) and I used a readonly with, for example, "R$30 limit".
The problem is that this value would change as the user changes the type of expense. For example: Assuming the user selects an X expense that has a limit of R$20
- If he selects this expense, he can only put in the value field (which is enabled by ) the maximum of R$20, more than this will be filled the R$20.
In my code below, I did only the test so that there is this field where the user can not change (in case the "R$30 limit").
<select name="tipoDespesa" required>
<option value="" disabled selected>Tipo</option>
<option>Almoço</option>
<option>Jantar</option>
</select>
<input type="number" name="precoDespesa" placeholder="R$" id="valor" step=".01" required placeholder="Insira um valor!">
<p><input type="text" name="limiteDespesa" id="limite" readonly value="Limite de R$30"></p>
What you want is: change the value of the second input according to what is selected in select?
– Lucas Pace
Yes, that would be the first step. The second is that, according to the value of the second input that will be changed, I cannot exceed that value in the first input.
– Gustavo R.
This is not a php-related issue but the front-end technology you’re using. What would that be? html/css/js/jquery/Vue..?
– Lucas Pace
i’m using html for the form, and for the css styles. sorry, I’m beginner, but I think that’s the answer
– Gustavo R.
I suggest you take a look at a language called javascript. With JS, you can display messages and other interesting information, make checks or dynamically change the visual presentation of the pages, depending on the behavior you want your page (or application) to have.
– Lucas Pace
With javascript you can easily change input values and attributes
– Lucas Pace
but I can put something directly in the code below with javascript? or I would have to redo all my code...
– Gustavo R.
You will need jquery
– user60252