Jump to content

dropdown error first choice


Go to solution Solved by litebearer,

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

  • Solution

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.