We have on the page the most common input. We cannot carry out any manipulations with the code of this form, that is, we can add anything only by means of js. It is necessary to turn input into a drop-down list. Picture to understand the issue.
In fact, you need to hide it and add the following code after it:
<div class="select"> <span class="placeholder">Выберите значение</span> <ul> <li data-value="es">Значение 1</li> <li data-value="en">Значение 2</li> <li data-value="fr">Значение 3</li> <li data-value="de">Значение 4</li> </ul> </div> The values from the data-value when selecting an item should fall into input, and the contents of the selected list item fall into the span.
There is a script for how this case can be implemented with access to editing the form, I will attach it for review, but there is no access to editing.
$('.select').on('click','.placeholder',function(){ var parent = $(this).closest('.select'); if ( ! parent.hasClass('is-open')){ parent.addClass('is-open'); $('.select.is-open').not(parent).removeClass('is-open'); }else{ parent.removeClass('is-open'); } }).on('click','ul>li',function(){ var parent = $(this).closest('.select'); parent.removeClass('is-open').find('.placeholder').text( $(this).text() ); parent.find('input[type=text]').attr('value', $(this).attr('data-value') ); }); .select li { cursor: pointer; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="select"> <span class="placeholder">Выбрать язык</span> <ul> <li data-value="es">Испанский</li> <li data-value="en">Английский</li> <li data-value="fr">Французский</li> <li data-value="de">Немецкий</li> </ul> <input type="text" name="myname"/> </div> Perhaps it will be possible to simply supplement this script. I would appreciate any help in this matter. Thank!
