I generate form with PHP and after clicking "Submit" button it opens new form. In new form after I click "Submit" button it forms fine and dosn't open new tab! So new tab opening applays only for the first time when page is loaded... first time i see something that weard.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
</head>
<body>
<?php
echo "<form method=\"get\" target=\"{$_SERVER['PHP_SELF']}\">";
echo "<select name=\"main_value\">";
echo "<option {$selected} value=\"{$city['ID']}\">{$city['NAME']}</option>";
echo "</select><br />";
echo "<input type=\"submit\" value=\"Submit!\" />";
echo "</form>";
?>
</body>
</html>
P.S. - ab course PHP variables exist - i just don't want to write whole code here!
Change this :
echo "<form method=\"get\" target=\"{$_SERVER['PHP_SELF']}\">";
to
echo "<form method=\"get\" action=\"{$_SERVER['PHP_SELF']}\">";
action
attribute is used to specify the script name to which the data is to be delivered. And target
attribute specifies in which window or frame the response is sent.
"Target" attribute of form is name of window in which the result of request must be displayed. For the first time there is no window with specified name, so new window (tab) opens. Next times browser already have the window with this name, so this window is used. If you want to open new tab each time, use target="_blank"
.