[Proto-Scripty] Re: how to change selectedIndex?

2008-09-19 Thread Luiz Paulo Camargo
Hi Cristisor,

I think that what are u seeking is more or less this code:



1990
1998
2000



1990
1995
1998




field = 'birthdate_smarty_select';
for(var i=0;i<$(field).childNodes.length;i++){
if($(field).childNodes[i].tagName == "SELECT") {
$(field).childNodes[i].selectedIndex = 0;
}
}


So, pay attention on index of childNodes (i) not always be 1 and 2 because
this I think its good do a FOR of all elements inside of SPAN and verify if
that element is a SELECT, if is put the value 0 using selectedIndex
statement, if not dont do anything.
I test this issue on Firefox and  IE 7 and works great.

Regards,

Luiz Paulo


On Fri, Sep 19, 2008 at 7:38 AM, Cristisor <[EMAIL PROTECTED]> wrote:

>
> Hi everyone. I have a small problem with IE. I have a span with the
> id="birthdate_smarty_select' and inside there are 2 "select" fields,
> one for day and the other one for year. I'm trying to set the default
> for the first value in both select fields like this:
> $(field).childNodes[1].selectedIndex = 0;
> $(field).childNodes[2].selectedIndex = 0;where
> field=birthdate_smarty_select
> it works just fine in FF but it won't work in IE :(
> >
>


-- 
Luiz Paulo Camargo

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: how to change selectedIndex?

2008-09-19 Thread Cristisor

It worked just fine on IE. Thanks Justin

On Sep 19, 5:32 pm, "Justin Perkins" <[EMAIL PROTECTED]> wrote:
> Why don't you use Prototype methods?
>
> $(field).select('select').each(function(control){
>   control.selectedIndex = 0;
>
> });
>
> -justin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: how to change selectedIndex?

2008-09-19 Thread Matt Foster

Be wary of using direct access to the childNodes array.  IE represents
all text nodes, even those that are just a newline character for your
HTML markup as an item in the childNodes array, so you're probably
referencing a text node instead of the select element you intended to.

I'd give the select element an id and reference them directly.


On Sep 19, 9:32 am, "Justin Perkins" <[EMAIL PROTECTED]> wrote:
> Why don't you use Prototype methods?
>
> $(field).select('select').each(function(control){
>   control.selectedIndex = 0;
>
> });
>
> -justin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: how to change selectedIndex?

2008-09-19 Thread Justin Perkins

Why don't you use Prototype methods?

$(field).select('select').each(function(control){
  control.selectedIndex = 0;
});

-justin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---