If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.
Register Today on DNForum IT'S FREE!I always see it on forums and stuff, when you go to edit your profile, your date of birth or whatever you put in a dropdown menu is shown to you, exactly how you selected it.
I have a form where people enter their date of birth, location etc, and I want it so when they go to edit, they see their selections already selected in the dropdown list by adding selected='selected' to it, I really cant figure out how to do it, and my only workaround right now is to add a duplicate at the top of the dropdown list.
I don't fully understand the question, but I'm guessing you are looking for a script that will populate a form based on the drop down menu?
Try this to get some ideas: http://www.codingforums.com/showthread.php?t=80345
Last edited by south; 03-20-2009 at 08:03 AM.
All offers good for 72 hours except running auctions
Progeria Research | Pulmonary Fibrosis | Dammit!
Here is one example.
The idea is that when the form loads, you retrieve their saved data from the DB. Let's just fetch their year of birth as an example.
Then you build your combo using a loop (here current year = 2009 through 1909). The year that matches your variable gets the selected attribute.
For XHTML compliant code use this insteadPHP Code:<?php
$link=mysql_pconnect("localhost","user","password");
mysql_select_db("db",$link);
$result = mysql_query("select date_format(birth_date,'%Y') as birth_year from members where member_id=1");
$row=mysql_fetch_array($result); // fetch first row
$year=$row["birth_year"]; // retrieve 4-digit year of birth
// display combo: current year -> -100
$current_year=date("Y");
echo '<select name="cbo_year">';
for ($i = $current_year; $i >= ($current_year-100); $i--) {
echo '<option '.($year == $i ? ' selected ' : '').' value="'.$i.'" >'.$i.'</option>';
}
echo '</select>';
?>
PHP Code:echo '<option '.($year == $i ? ' selected="selected " ' : '').' value="'.$i.'" >'.$i.'</option>';
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
Thankyou!
That was exactly what I was looking for with regards to their date of birth, but my biggest pain is Location of the users, with a long dropdown list is there an easy way about it? Its not really important, im just looking to have things working properly, if its too much hassle for me I may just duplicate their location such as "United States" at the top of the list.
Bookmarks