Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting the initial value of an HTML list

2 views
Skip to first unread message

Derek @ Blueyonder

unread,
Aug 28, 2009, 10:28:33 AM8/28/09
to
Hi

I have a list, similar to the one below, how do I get it to show a
particular value rather than always starting at 01?

I would like to be able to get it to show the current date number, i.e. on
the 15th of a month the list would show 15..

Any assistance would be appreciate.

Many thanks

Derek


<select name="selectday" id="selectday">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>


John Hosking

unread,
Aug 30, 2009, 2:24:04 PM8/30/09
to
On Fri, 28 Aug 2009 15:28:33 +0100, Derek @ Blueyonder wrote:

> I have a list, similar to the one below, how do I get it to show a
> particular value rather than always starting at 01?

I believe you want the attribute "selected".

I believe you also want to know about HTMLDog, a great tutorial and
reference site for HTML (and CSS as well). Here's the page where I found
your answer: <http://www.htmldog.com/reference/htmltags/option/>

The canonical reference site is, of course, the W3C:

<http://www.w3.org/>
<http://www.w3.org/TR/html401/>
<http://www.w3.org/TR/html401/interact/forms.html#h-17.6.1>

>
> I would like to be able to get it to show the current date number, i.e. on
> the 15th of a month the list would show 15..

...


<option value="14">14</option>

<option value="15" selected>15</option>


<option value="16">16</option>

...

as at the W3C. The HTMLDog offers it as:

...


<option value="14">14</option>

<option value="15" selected="selected">15</option>


<option value="16">16</option>

...


The two forms are equivalent and valid, since selected is a boolean
attribute, and can be written in something called minimized form:
<http://www.w3.org/TR/html401/intro/sgmltut.html#didx-boolean_attribute-1>

You'll want to test in many browsers, as usual.


>
> <select name="selectday" id="selectday">
> <option value="01">01</option>

[rest snipped]
> </select>

Two more things:

If you had read this group before posting you might have noticed its low
article count. It's all but dead (or I am the undead). You might also look
at comp.infosystems.www.authoring.html (currently quiet as well, but with
more subscribers).

If you want to munge your e-mail address, you might do better to use a
clearly non-valid address, like <derek...@blueyonder.co.uk.INVALID>.
Yours is possibly valid and some spammer might attempt to send mail to it,
causing servers to attempt delivery. No server is supposed to send or
forward mail (or HTTP requests) to an .invalid domain.
See <http://en.wikipedia.org/wiki/.invalid>

HTH

--
John

Net5

unread,
Sep 10, 2009, 5:59:16 PM9/10/09
to
On the 'option' you want as the default selected option, use this
form:

<option selected value="03" >03</option>


On Fri, 28 Aug 2009 15:28:33 +0100, "Derek @ Blueyonder"

Derek @ Blueyonder

unread,
Sep 21, 2009, 2:19:10 PM9/21/09
to

"Net5" <P...@NeT5.cm> wrote in message
news:tgtia5lsdbcvcu5e8...@4ax.com...

> On the 'option' you want as the default selected option, use this
> form:
>
> <option selected value="03" >03</option>
>
>
Thank you all, it know it has been a while since the answers were posted but
only just had time to get this sorted this afternoon.

Many thanks

Derek


0 new messages