colouredFunk Posted May 22, 2007 Share Posted May 22, 2007 Hello, I want to be able to have a drop down list that doesn't necessarily have the first item as the default. The content is being populated by PHP so I have no idea how to do it. Please help. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/52460-solved-dropdown-default-value/ Share on other sites More sharing options...
jitesh Posted May 22, 2007 Share Posted May 22, 2007 Example <select name="select"> <?php for($i=0;$i<100;$i++){ if($i == $default_value){ $selected = "selected"; }else{ $selected = ""; } ?> <option value="<?php echo $i;?>" <?php echo $selected;?>><?php echo $i;?></option> <? } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/52460-solved-dropdown-default-value/#findComment-258844 Share on other sites More sharing options...
OOP Posted May 22, 2007 Share Posted May 22, 2007 Hi there, if I understood your requirements correctly...I am not sure if you can do this or not...but you can add an empty line as your first option. maybe some else knows the answer Quote Link to comment https://forums.phpfreaks.com/topic/52460-solved-dropdown-default-value/#findComment-258847 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.