T
T
testtoster2020-03-12 09:12:03
htaccess
testtoster, 2020-03-12 09:12:03

How to select the first element from a list?

There is a small list. How to select the first element (option) from the list in js?

<select  onchange="window.location.href=this.value">
<option value="" disabled="" selected="">Выберите город</option><option value="/abhaziya">Абхазия</option>
<option value="/bagdad">Багдад</option><option value="//localhost:3000/partners/vashington">Вашингтон</option>
<option value="/omsk">Омск</option>
</select>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Gennady S, 2019-08-03
@gscraft

You need this .htaccess documentation , namely:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f # убедитесь, что это не реальный файл
RewriteRule ^([a-z]+)\.gif$ file.php?user=$1 # если совпадет регулярное выражение, перенаправляет запрос на file.php

But it is better to solve this using PHP, a routing library, or a microframework , since it will be incorrect to configure .htaccess for each task of a web application (and complicate the server change).

V
Viktor Taran, 2019-08-05
@shambler81

GET is not part of the url, so it stands out separately

RewriteCond %{QUERY_STRING} (^|&)user\=(.+)($|&)
RewriteCond %{QUERY_STRING} (^|&)data\=(.+)($|&)
RewriteRule ^file\.php$ /file.php\?user\=%2\&data\=%5 [L,R=301]

S
Sergey Suntsev, 2020-03-12
@testtoster

Document.querySelectorAll('option')[0]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question