Page 1 of 1
another select question-- selected='selected' can't change?
Posted: Sat Sep 24, 2005 2:35 pm
by Skara
Alright, this is screwy. I have three date dropdowns (day, month, year). Now when the page first loads, I have it put selected='selected' if the date is today.
e.g.
Code: Select all
<select name='day'>
<option>23</option>
<option selected='selected'>24</option>
<option>25</option>
</select>
The problem is, whenever I change it... it doesn't really change. It still uses the value from whatever the one is marked as 'selected.'
How can I have today active when the page loads, but read whatever the user enters?
Posted: Sat Sep 24, 2005 2:47 pm
by Charles256
because you don't write selected='selected' you just write selected and that's it.
Posted: Sat Sep 24, 2005 2:53 pm
by Skara
Posted: Sat Sep 24, 2005 2:57 pm
by Charles256
whatever man . just telling you what i have working on my site.

if it messes up in the next browser release i'll look into it more:)
Posted: Sat Sep 24, 2005 3:05 pm
by pilau
Maybe that is not supported by your browser.
Posted: Sat Sep 24, 2005 3:15 pm
by Skara
-_-' Firefox 1.0.7. I'm fairly certain it supports xhtml. *sighs*
Posted: Sat Sep 24, 2005 3:52 pm
by John Cartwright
http://en.wikipedia.org/wiki/XHTML#XHTML_1.0
Attribute minimization (e.g., <option selected>) is also prohibited; instead, use <option selected="selected">. More differences are detailed in the W3C XHTML specification [
1].
which will lead you to
C.10. Boolean Attributes
Some HTML user agents are unable to interpret boolean attributes when these appear in their full (non-minimized) form, as required by XML 1.0. Note this problem doesn't affect user agents compliant with HTML 4. The following attributes are involved: compact, nowrap, ismap, declare, noshade, checked, disabled, readonly, multiple, selected, noresize, defer.
Posted: Sat Sep 24, 2005 4:01 pm
by John Cartwright
Code: Select all
$dropdown = '<select name="day">';
for ($x = 0; $x <= date('t',time()); $x++) {
$dropdown .= '<option value="'.$x.'"';
if (isset($_POST['day']) && $x == $_POST['day']) {
$dropdown .= 'selected="selected"';
}
else if ($x == date('j',time()){
$dropdown .= 'selected="selected"';
}
$dropdown .= '>';
}
$dropdown .= '</select>';
Posted: Sat Sep 24, 2005 9:14 pm
by Skara
Eheh... uhm. Figured my problem out!
I'm uploading multiple files with bunches of data otherwise. I got myself confused on the many-dimentional arrays again. It kept trying to read the last one for all of them. ^^;
Thanks anyway...

Posted: Sat Sep 24, 2005 11:19 pm
by pilau
Wikipedia wrote:C.10. Boolean Attributes
Some HTML user agents are unable to interpret boolean attributes when these appear in their full (non-minimized) form, as required by XML 1.0. Note this problem doesn't affect user agents compliant with HTML 4. The following attributes are involved: compact, nowrap, ismap, declare, noshade, checked, disabled, readonly, multiple, selected, noresize, defer.
See? Told you so.
Posted: Sun Sep 25, 2005 11:54 am
by Skara
Hm. But nevertheless Firefox works fine on them. I've got giant multidimentional POST and FILES arrays and it all works spiffy now.
I have IE, Opera, Konqueror, lynx, etc.. that I use to test my sites I do and it works just fine. I think this misinterpretation bug isn't a very large one. Even if it was once, most browsers would have tried to fix it now. *shrugs*