Select stops to submit after two selections

I have a strange problem. I want to submit a value from a select input to a text input only when I select something (onchange='submit()') . When I select this value, it must keep to be selected. The text input can also submit its value to the select input through the comparison and selection.

I wrote this code but the input select stops to submit after 2 selections. Why? Thank you in advance!

echo"<form method='post' action='".htmlspecialchars($_SERVER["PHP_SELF"])."'>";
echo"<br><br><br><select id='users' name='users'"; if(!$_POST['username']) {
    echo "onchange='submit()'";
foreach($users_array as $auxvar_user_name) {
    echo "<option value='".$auxvar_user_name."'"; 
    if ($_POST['users'] == $auxvar_user_name) {
        echo" selected='selected'";
echo "</select>";
echo"<br><br><br><input type='text' id='username' name='username' value='".$_POST['users']."'"; 
if(!$_POST['users']) {
    echo "onchange='submit()'";
echo" />";

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s