"Selected" Attribute in <option> tag, Not working...maybe somone can help? |
"Selected" Attribute in <option> tag, Not working...maybe somone can help? |
*mipadi* |
![]()
Post
#1
|
Guest ![]() |
Hi,
This isn't really related to my blog, but it's related to a website I am working on. Basically I working with entries in a database. The page in question is attempting to edit an existing entry. One of the data fields is a date. I'm trying to create a menu that will allow the user to change the day; however, the existing day is supposed to be pre-selected. Unfortunately, the day is defaulting to 1, not the selected day--even though selected is set in the <option> tag. Here is the HTML: CODE <select name="EventDateDay"> <option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9" selected>9</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> Note that the proper value ("9") does in fact have the selected attribute set, but the page is still drawn with 1 as the default. It's also interesting to note that it works properly in IE, but not Firefox. Here is the script I wrote to select the proper value (it's in VBScript because this is an ASP site): CODE <select name="EventDateDay"> <% For i = 1 to 31 If i = Day(eventDate) Then Response.Write "<option value=""" & i & """ selected>" & i & "</option>" Else Response.Write "<option value=""" & i & """>" & i & "</option>" End If Next %> </select> "eventDate" is the variable that holds the date for the database record I am pulling. |
|
|
![]() |
*mipadi* |
![]()
Post
#2
|
Guest ![]() |
Never mind, the problem has been fixed. Seems to have something to do with Firefox not fully refreshing the HTML when the source code of a page is changed. It works fine if all the changes to the scripting are made, then the page is closed and re-opened. Interesting...
|
|
|
*mona lisa* |
![]()
Post
#3
|
Guest ![]() |
QUOTE(mipadi @ Jun 6 2005, 2:23 PM) Never mind, the problem has been fixed. Seems to have something to do with Firefox not fully refreshing the HTML when the source code of a page is changed. It works fine if all the changes to the scripting are made, then the page is closed and re-opened. Interesting... ![]() |
|
|
![]() ![]() |