Jump to content

dropdown error first choice


rodo

Recommended Posts

Hello everyone, this is my first post..jeje

 

 I've a problem with a simple dropdown, the dropdown is populated with mysql table, and everything works fine, but when I use the submit button, in the save.php  doesn't get the first choice of the dropdown! if I select 2nd o 3rd or other..it works..but when I choose the first  it return empty..

 

here my code: 

 

EDIT.PHP

 

 

 <div class="form-row row-fluid">
     <label class="form-label span4" for="tipoproveedor">Tipo Proveedor</label> 
     <div class="span7 controls">
          <select  name="selectTipoProveedor" id="selectTipoProveedor">
                  <option VALUE=<? while ($rowTipoProveedor=mysql_fetch_array($resultTipoProveedor)){
                                                        if($rowTipoProveedor['ClaTipoProveedor'] == $row->ClaTipoProveedor)
                                                            echo '<option selected="selected" value='.$rowTipoProveedor['ClaTipoProveedor'].'>' .$rowTipoProveedor['NomTipoProveedor']. '</option>';
                                                        else
                                                            echo'<option value='.$rowTipoProveedor['ClaTipoProveedor'].'>'.$rowTipoProveedor['NomTipoProveedor'].'</option>';
                                                    }?>
                   </option>
          </select>
  </div>
</div>

 

 

SAVE.PHP

....

 

$tipoprov  = $_POST[selectTipoProveedor];

$test =   "<h2 class=>".$tipoprov."</h2>";

 

 

...

 

Thanks in advance!

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/281025-dropdown-error-first-choice/
Share on other sites

Effectively, you are placing an <option></option> within an option. Your while loop should begin immediately after your opening select and end immediately prior to your closing select. If you look closely at your browser source you should see what is happening

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.