This is a WebKit (both Safari & Chrome) issue, since it handles
attributes more strictly than other browsers. I.e. 'selected' is not
an attribute on the HTML node, just a property. We try to work around
this in most cases by setting both the attribute and the property just
to be sure:

                    if (typeof(elem[k]) == "string" && elem[k] != v) {
                        // Also set property for weird attributes (see #302)
                        elem[k] = v;
                    }

But in WebKit typeof(elem.selected) == "boolean", so this fix doesn't
run... Perhaps we should add a patch for the patch here. Don't know if
it will be safe, but it might work.

The easy work-around for you is to do the following instead:

       function getAnalogueInputs(){
          var node = getElement('[AN1_MEASURING_Q]');
          // FIXME: the next line will always return 1... probably not intended
          var type = getSignalTypeAsIndex(node[0]);
          var opt = node.options[type];
          opt.selected = 'selected';
       }

Cheers,

/Per

On Mon, Dec 8, 2008 at 11:20 AM, [email protected]
<[email protected]> wrote:
>
> Hi,
>
> Thanks for the reply. There is no error shown in Google Chrome. Here
> is a test file.
>
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <!--<script type="text/javascript" src="MochiKit-1.3.1/lib/MochiKit/
> MochiKit.js"></script>-->
> <script type="text/javascript" src="MochiKit-1.4/lib/MochiKit/
> MochiKit.js"></script>
> <title></title>
> </head>
> <body>
> <form action="">
> <div style="margin-left:5px">
> <h2>Analogue Inputs</h2></div>
>
> <!--AN1-->
> <div class="an">
> <h3>&nbsp;</h3>
> <div class="tableDataGrey" style="width:130px;">
>  <label>Measuring Quantity
>  <select name="an1MeasuringQ" size="1"  id="[AN1_MEASURING_Q]">
>    <option value="level" >Level</option>
>    <option value="pressure" >Pressure</option>
>  </select>
>  </label>
>  </div>
> </div>
>
> </form>
> </body>
> </html>
>
> <script type="text/javascript">
>
>        function getAnalogueInputs(){
>
>                                var node = 'pressure';
>                                node = getElement('[AN1_MEASURING_Q]');
>                                
> setNodeAttribute(node.options[getSignalTypeAsIndex(node
> [0])],'selected','selected');
>
>
>        }
>
>
>        function getSignalTypeAsIndex(type){
>
>
>                        if(type == "level")
>                                return 0;
>                        else
>                                return 1;
>
>
>
>        }
>
>        connect(window, 'onload',
>                function() {
>                                getAnalogueInputs();
>                        }
>        );
>
>
>
>
>
> </script>
>
> On Dec 7, 11:10 pm, "Per Cederberg" <[email protected]> wrote:
>> If you could provide more details on exactly what is breaking it would
>> be easier to help. Perhaps a minimal HTML file exposing the issue? If
>> you can find any error or debugging information from Chrome (if there
>> is any) that too would be very helpful.
>>
>> Cheers,
>>
>> /Per
>>
>> On Sun, Dec 7, 2008 at 8:49 PM, [email protected]
>>
>> <[email protected]> wrote:
>>
>> > Hi,
>>
>> > The following code doest work with Google Chrome but is OK with
>> > firefox and IE7
>>
>> >                        node = getElement('[AN3_PRE_ALARM_ACTION]');
>> >                        setNodeAttribute(node.options[getActionAsIndex(d.an3
>> > [7])],'selected','selected');
>>
>> > Any thoughts?
>>
>> > Regards,
>> > Nick
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to