select an index of a select in html and based on it affect another Javascript element

2

Hi, I have time looking for an answer to this, what I want is that when I select an option of my select I can change the text of an imput                                                               Request:

                                     General Management                     Academic Subdirection                     Subdirection of Administrative Services                     Subdireccion de Planeacion y Vinculacion                                            
                   <p style="margin-bottom: 0px;margin-left: 100px;margin-top: 10px;">Nombre del o la responsable de la informacion: </p>
                   <input id="respo" style="margin-bottom: 5px;margin-left: 40px;width: 400px;" name="responsable" type="text" aria-disabled="true" placeholder=""><br>
                   <input style="margin-left: 150px;height: 40px;width: 200px;margin-bottom: 10px;" type="submit" value="Enviar">
               </div>
           </div>
        </form>
    </div>
         </body>
     </html>
    
asked by Egogela 24.02.2018 в 01:54
source

1 answer

1

If I think I have understood your question, you have to trigger a trigger via jquery:

var nuevoValor = "El valor que quieras que tome el input text al hacer el change";
$.('#miSelect').change(function(){
    $('#miInput').val(nuevoValor);
});

If the value you want to change is related to the text of the select option, it could be done like this:

$.('#miSelect').change(function(){
    $('#miInput').val($(this).text());
});

Greetings.

    
answered by 24.02.2018 / 12:05
source