Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Setting the selected option in Safari 3
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting the selected option in Safari 3




On Aug 22, 2007, at 06:56 , Nico du Plessis wrote:

I have logged a bug report.

I don't think is a bug, because according to HTML 4.01 spec :

It is considered an error if more than one OPTION element has the selected attribute set and the SELECT element does not have the multiple attribute set. User agents may vary in how they handle this error, but should not pre-select more than one choice.

So, without any selected element, the first one is already selected, selecting another do like the spec says. Firefox is wrong this time, sorry.



It seems to be consistent with all of the doctypes.
Here is the code that I use to recreate the problem.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<!-- other doctypes -->
<!--
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd";>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd";>
-->

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>javascript_bug</title>
	<script type="text/javascript" charset="utf-8">
		function setElement()
		{
			var select = document.getElementById('list');
			select.options[3].selected = true;
		}
	</script>
</head>

<body>

<h2> Form </h2>

<form action="" method="get" accept-charset="utf-8">
<select id="list">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
<option>Option 5</option>
</select>

<input type="button" name="some_name" value="Change the selected index" id="some_name" onclick="setElement()">
</form>


</body>
</html>



On 22 Aug 2007, at 10:38 AM, Nico du Plessis wrote:

Have you logged a bug report with Apple yet?

On 22 Aug 2007, at 9:46 AM, Nico du Plessis wrote:

Funny you should send this mail.
I have just been sitting here for an hour trying to figure out what I am doing wrong in my javascript.
I have the same problem


Regards,

Nico du Plessis

On 22 Aug 2007, at 6:38 AM, Lee Hinde wrote:

I posted this on the jQuery list with no love, so I thought I'd try here:


Hi;

Based on this conversation: http://tinyurl.com/2qwpna

I've added this code to my page

       function updateColor()
       {
          var currentColor = $("#setColorKey").val();

          $("#color_Key option").each(function()
          {
             // $(this) is the current <option> element
             var thisValue = $(this).val();
             if (thisValue == currentColor){
                $(this).attr("selected", true);
                     //safari logging.
                       if(window.console)
{window.console.log($(this).attr("selected")+" "+thisValue);}
                               return false;
                       }
          });
       }


The problem is, on Safari 3. the option doesn't get selected. It works
fine in Firefox/Camino.


The Safari javascript console shows the log entry, but doesn't update
the select.




--
"And those are my principles. If you don't like them, I have others" -
Groucho Marx
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Web-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Web-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40xfer.info


This email sent to email@hidden



:: marcelo.alves - Where was life when it had a meaning ?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Setting the selected option in Safari 3 (From: "Lee Hinde" <email@hidden>)
 >Re: Setting the selected option in Safari 3 (From: Nico du Plessis <email@hidden>)
 >Re: Setting the selected option in Safari 3 (From: Nico du Plessis <email@hidden>)
 >Re: Setting the selected option in Safari 3 (From: Nico du Plessis <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.