Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Hod do I remove default value in a drop down menu?
Old 01-25-2009, 04:13 PM Hod do I remove default value in a drop down menu?
Experienced Talker

Posts: 38
Name: carl
Trades: 0
I have the following form. IT works fine, but it always has a default selection in the drop down menus. By default it is a blank, but if you submit it sends a blank to my database. I have a script set up that puts out an error if nothing is entered, but this blank is being sent. I need to make the drop downs send no data unless somethign is actually selected. How can I do this exactly?

Code:
<select name="country">
<option></option>      
<option>United States</option><br />
    <option>China</option><br />

    <option>Japan</option><br />
    <option>Germany</option><br />
    <option>India</option><br />
    <option>Brazil</option><br />
    <option>United Kingdom</option><br />
    <option>Korea</option><br />

    <option>France</option><br />
    <option>Italy</option><br />
    <option>Russia</option><br />
    <option>Mexico</option><br />
    <option>Canada</option><br />
    <option>Spain</option><br />

    <option>Indonesia</option><br />
    <option>Vietnam</option><br />
    <option>Turkey</option><br />
    <option>Australia</option><br />
    <option>Taiwan</option><br />
    <option>Philippines</option><br />

    <option>Afghanistan</option><br />
    <option>Albania</option><br />
    <option>Algeria</option><br />
    <option>American Samoa</option><br />
    <option>Andorra</option><br />
    <option>Anguilla</option><br />

    <option>Antarctica</option><br />
    <option>Antigua And Barbuda</option><br />
    <option>Argentina</option><br />
    <option>Armenia</option><br />
    <option>Aruba</option><br />
    <option>Australia</option><br />

    <option>Austria</option><br />
    <option>Azerbaijan</option><br />
    <option>Bahamas</option><br />
    <option>Bahrain</option><br />
    <option>Bangladesh</option><br />
    <option>Barbados</option><br />

    <option>Belarus</option><br />
    <option>Belgium</option><br />
    <option>Belize</option><br />
    <option>Benin</option><br />
    <option>Bermuda</option><br />
    <option>Bhutan</option><br />

    <option>Bolivia</option><br />
    <option>Bosnia and Herzegovina</option><br />
    <option>Botswana</option><br />
    <option>Bouvet Island</option><br />
    <option>Brazil</option><br />
    <option>British Indian Ocean Territory</option><br />

    <option>Brunei Darussalam</option><br />
    <option>Bulgaria</option><br />
    <option>Burkina Faso</option><br />
    <option>Burundi</option><br />
    <option>Cambodia</option><br />
    <option>Cameroon</option><br />

    <option>Canada</option><br />
    <option>Cape Verde</option><br />
    <option>Cayman Islands</option><br />
    <option>Central African Republic</option><br />
    <option>Chad</option><br />
    <option>Chile</option><br />

    <option>China</option><br />
    <option>Christmas Island</option><br />
    <option>Cocos (Keeling) Islands</option><br />
    <option>Colombia</option><br />
    <option>Comoros</option><br />
    <option>Congo</option><br />

    <option>Congo, the Democratic Republic of the</option><br />
    <option>Cook Islands</option><br />
    <option>Costa Rica</option><br />
    <option>Cote d’Ivoire</option><br />
    <option>Croatia</option><br />
    <option>Cyprus</option><br />

    <option>Czech Republic</option><br />
    <option>Denmark</option><br />
    <option>Djibouti</option><br />
    <option>Dominica</option><br />
    <option>Dominican Republic</option><br />
    <option>East Timor</option><br />

    <option>Ecuador</option><br />
    <option>Egypt</option><br />
    <option>El Salvador</option><br />
    <option>England</option><br />
    <option>Equatorial Guinea</option><br />
    <option>Eritrea</option><br />

    <option>Espana</option><br />
    <option>Estonia</option><br />
    <option>Ethiopia</option><br />
    <option>Falkland Islands</option><br />
    <option>Faroe Islands</option><br />
    <option>Fiji</option><br />

    <option>Finland</option><br />
    <option>France</option><br />
    <option>French Guiana</option><br />
    <option>French Polynesia</option><br />
    <option>French Southern Territories</option><br />
    <option>Gabon</option><br />

    <option>Gambia</option><br />
    <option>Georgia</option><br />
    <option>Germany</option><br />
    <option>Ghana</option><br />
    <option>Gibraltar</option><br />
    <option>Great Britain</option><br />

    <option>Greece</option><br />
    <option>Greenland</option><br />
    <option>Grenada</option><br />
    <option>Guadeloupe</option><br />
    <option>Guam</option><br />
    <option>Guatemala</option><br />

    <option>Guinea</option><br />
    <option>Guinea-Bissau</option><br />
    <option>Guyana</option><br />
    <option>Haiti</option><br />
    <option>Heard and Mc Donald Islands</option><br />
    <option>Honduras</option><br />

    <option>Hong Kong</option><br />
    <option>Hungary</option><br />
    <option>Iceland</option><br />
    <option>India</option><br />
    <option>Indonesia</option><br />
    <option>Ireland</option><br />

    <option>Israel</option><br />
    <option>Italy</option><br />
    <option>Jamaica</option><br />
    <option>Japan</option><br />
    <option>Jordan</option><br />
    <option>Kazakhstan</option><br />

    <option>Kenya</option><br />
    <option>Kiribati</option><br />
    <option>Korea, Republic of</option><br />
    <option>Korea (South)</option><br />
    <option>Kuwait</option><br />
    <option>Kyrgyzstan</option><br />

    <option>Lao People’s Democratic Republic</option><br />
    <option>Latvia</option><br />
    <option>Lebanon</option><br />
    <option>Lesotho</option><br />
    <option>Liberia</option><br />
    <option>Libya</option><br />

    <option>Liechtenstein</option><br />
    <option>Lithuania</option><br />
    <option>Luxembourg</option><br />
    <option>Macau</option><br />
    <option>Macedonia</option><br />
    <option>Madagascar</option><br />

    <option>Malawi</option><br />
    <option>Malaysia</option><br />
    <option>Maldives</option><br />
    <option>Mali</option><br />
    <option>Malta</option><br />
    <option>Marshall Islands</option><br />

    <option>Martinique</option><br />
    <option>Mauritania</option><br />
    <option>Mauritius</option><br />
    <option>Mayotte</option><br />
    <option>Mexico</option><br />
    <option>Micronesia, Federated States of</option><br />

    <option>Moldova, Republic of</option><br />
    <option>Monaco</option><br />
    <option>Mongolia</option><br />
    <option>Montserrat</option><br />
    <option>Morocco</option><br />
    <option>Mozambique</option><br />

    <option>Myanmar</option><br />
    <option>Namibia</option><br />
    <option>Nauru</option><br />
    <option>Nepal</option><br />
    <option>Netherlands</option><br />
    <option>Netherlands Antilles</option><br />

    <option>New Caledonia</option><br />
    <option>New Zealand</option><br />
    <option>Nicaragua</option><br />
    <option>Niger</option><br />
    <option>Nigeria</option><br />
    <option>Niue</option><br />

    <option>Norfolk Island</option><br />
    <option>Northern Ireland</option><br />
    <option>Northern Mariana Islands</option><br />
    <option>Norway</option><br />
    <option>Oman</option><br />
    <option>Pakistan</option><br />

    <option>Palau</option><br />
    <option>Panama</option><br />
    <option>Papua New Guinea</option><br />
    <option>Paraguay</option><br />
    <option>Peru</option><br />
    <option>Philippines</option><br />

    <option>Pitcairn</option><br />
    <option>Poland</option><br />
    <option>Portugal</option><br />
    <option>Puerto Rico</option><br />
    <option>Qatar</option><br />
    <option>Reunion</option><br />

    <option>Romania</option><br />
    <option>Russia</option><br />
    <option>Russian Federation</option><br />
    <option>Rwanda</option><br />
    <option>Saint Kitts and Nevis</option><br />
    <option>Saint Lucia</option><br />

    <option>Saint Vincent and the Grenadines</option><br />
    <option>Samoa (Independent)</option><br />
    <option>San Marino</option><br />
    <option>Sao Tome and Principe</option><br />
    <option>Saudi Arabia</option><br />
    <option>Scotland</option><br />

    <option>Senegal</option><br />
    <option>Serbia and Montenegro</option><br />
    <option>Seychelles</option></p>
<p>    <option>Sierra Leone</option><br />
    <option>Singapore</option><br />
    <option>Slovakia</option><br />

    <option>Slovenia</option><br />
    <option>Solomon Islands</option><br />
    <option>Somalia</option><br />
    <option>South Africa</option><br />
    <option>South Georgia and the South Sandwich Islands</option><br />
    <option>South Korea</option><br />

    <option>Spain</option><br />
    <option>Sri Lanka</option><br />
    <option>St. Helena</option><br />
    <option>St. Pierre and Miquelon</option><br />
    <option>Suriname</option><br />
    <option>Svalbard and Jan Mayen Islands</option><br />

    <option>Swaziland</option><br />
    <option>Sweden</option><br />
    <option>Switzerland</option><br />
    <option>Taiwan</option><br />
    <option>Tajikistan</option><br />
    <option>Tanzania</option><br />

    <option>Thailand</option><br />
    <option>Togo</option><br />
    <option>Tokelau</option><br />
    <option>Tonga</option><br />
    <option>Trinidad</option><br />
    <option>Trinidad and Tobago</option><br />

    <option>Tunisia</option><br />
    <option>Turkey</option><br />
    <option>Turkmenistan</option><br />
    <option>Turks and Caicos Islands</option><br />
    <option>Tuvalu</option><br />
    <option>Uganda</option><br />

    <option>Ukraine</option><br />
    <option>United Arab Emirates</option><br />
    <option>United Kingdom</option><br />
    <option>United States</option><br />
    <option>United States Minor Outlying Islands</option><br />
    <option>Uruguay</option><br />

    <option>Uzbekistan</option><br />
    <option>Vanuatu</option><br />
    <option>Vatican City State (Holy See)</option><br />
    <option>Venezuela</option><br />
    <option>Viet Nam</option><br />
    <option>Virgin Islands (British)</option><br />

    <option>Virgin Islands (U.S.)</option><br />
    <option>Wales</option><br />
    <option>Wallis and Futuna Islands</option><br />
    <option>Western Sahara</option><br />
    <option>Yemen</option><br />
    <option>Zambia</option><br />

    <option>Zimbabwe</option><br />
</select>
Exbrief is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-25-2009, 04:30 PM Re: Hod do I remove default value in a drop down menu?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Well if you assign each option with a value you will be able to check/reject if a value is submitted.

HTML Code:
<option value="hello">Hello</option>
<option value="bye">Bye</option>
*EDIT*
1) Take out the Blank option tag at the start.

2) You can set the default selected option by using the:
HTML Code:
<option value="hello" selected="selected">Hello</option>
3) I would suggest using the ISO 3166-1 alpha-2 Country Codes for the value="" attributes.

4) You don't need the <br /> after each option.

5) If you alphabetize the countries it will help out the users
5.1) Or place the most common countries first but also include them below in the "full" list.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


Last edited by Decaf; 01-25-2009 at 04:35 PM..
Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 01-25-2009, 04:36 PM Re: Hod do I remove default value in a drop down menu?
Experienced Talker

Posts: 38
Name: carl
Trades: 0
ok, how do I have NO SELECTION to start with?
Exbrief is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 06:52 PM Re: Hod do I remove default value in a drop down menu?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
put in a option of "No Selection" or "-- Select Country --" first in the options list with a value of ""
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-25-2009, 07:08 PM Re: Hod do I remove default value in a drop down menu?
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
I don't think that there is a way to have nothing already selected. So If I were you, I would keep in the blank tag, or as Chris suggested, have something like "No Selection". Then to keep people to keep from sending blank info to the database (or whatever), you could add in some code similar to:
Code:
<?php
$country = $_POST['country'];
if($_POST['submit']){
    if($country == 'none') {
    echo "Please select a country.";
    } else {
    echo "Thank ye kindly for selecting a country...";
    }
}
?>

<form method="post">
<select name="country">
<option value="none"></option>   
<option value="1">option 1</option>
<option value="2">option 2</option>
</select>
<input type="submit" value="submit" name="submit" />
</form>

- Steve
stevej is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 07:10 PM Re: Hod do I remove default value in a drop down menu?
Experienced Talker

Posts: 38
Name: carl
Trades: 0
ok, I tried that, but for some reason the form is just submitting blanks to the database. The php script stops this and returns an error message whenever there is no data to send, but for some reason the html form is telling the php script there is in fact data, when in fact there is not. Anyone have any ideas? I have to have this work correctly so I dont get 1000+ blank recods, lol.
Exbrief is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 07:13 PM Re: Hod do I remove default value in a drop down menu?
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
Wow, that was a speedy reply. Keep in mind: that the <option value="none></option> is very important for it to work. Without the value, the code doesn't get that value it's looking for and thinks that everything's fine.

- Steve
stevej is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 08:04 PM Re: Hod do I remove default value in a drop down menu?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by stevej View Post
Wow, that was a speedy reply. Keep in mind: that the <option value="none></option> is very important for it to work. Without the value, the code doesn't get that value it's looking for and thinks that everything's fine.

- Steve
Yep...
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 01-25-2009, 08:11 PM Re: Hod do I remove default value in a drop down menu?
Experienced Talker

Posts: 38
Name: carl
Trades: 0
it still thinks its getting some data, it is still creating database entries even with no data entered into the form.


I even just did a copy/paste of your exact code above, it still does not care.
Exbrief is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 08:15 PM Re: Hod do I remove default value in a drop down menu?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
need the PHP code you are using AND a link to the page.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Hod do I remove default value in a drop down menu?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.59971 seconds with 12 queries