Change input value according to an option’s value

Asked

Viewed 98 times

0

I am trying to develop a differentiated functionality for study purposes and so far failed to develop.

What I need to do:

I’m gonna have a field input of the kind hidden and needed it to earn the same value that was assigned (as selected) in the option of a select. Follows the code:

<form id="formulario">
<!--
Aqui deixei o value vazio para fins de entender o que da pra fazer com ele.
 -->
    <input type="hidden" name="categoriaId" value="">

    <select class="categorias_select" name="categoria_id" tabindex="-1" aria-hidden="true">
        <option value="14"> CATEGORIA 01 </option>
        <option value="15"> CATEGORIA 02 </option>
        <option value="16" selected="selected"> CATEGORIA 03 </option>
        <option value="17"> CATEGORIA 04 </option>
        <option value="18"> CATEGORIA 05 </option>
    </select>
</form>

So when I select the Category 01 the value of input mute to 14.

I managed to do it just with PHP but I want to understand to do this process through the javascript/jQuery

I hope to understand the idea and I will be here for more information.

Thank you all for your help. Grateful!

  • 1

    Lougans, I think the second question on the list should solve. QQ thing warns there.

  • @Sam Mano, vlw.. the second list question helped me yes. Wow, I thought I’d have to do a lot of haha associations.. Vlw bro.

No answers

Browser other questions tagged

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