|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
I'm relativly new to js, can't get this to work<script type="text/javascript"> var W3CDOM = (document.createElement && document.getElementsByTagName); var focusON = new Array(); var focusOFF = new Array(); window.onload = init; function init() { if (!W3CDOM) return; var parent = document.getElementById('commentform'); var child = parent.getElementsByTagName('input'); for (var i=0;i<child.length;i++) { child[i].onfocus = focusON; child[i].onblur = focusOFF; } } function focusON() { this.style.borderBottom="1px solid #333"; } function focusOFF() { this.style.borderBottom="1px solid #000"; } </script> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Behaviour Javascript Library" group. To post to this group, send email to behaviour@... To unsubscribe from this group, send email to behaviour-unsubscribe@... For more options, visit this group at http://groups.google.com/group/behaviour?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: I'm relativly new to js, can't get this to workThat is quite atrocious code - but I see what you're trying to do.
child[i].onfocus = focusON.bind(child[i]); will do what you want if you include prototype.js. You should read up on using prototype properly to do classes and binding and Event.observe - that'll make your js life a lot happier. :) Ben On 8/18/07, guzguz <codenameguzguz@...> wrote:
-- Regards, Ben Nolan http://bennolan.com/ skype: bennolan cell: +49 1577 383 7542 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Behaviour Javascript Library" group. To post to this group, send email to behaviour@... To unsubscribe from this group, send email to behaviour-unsubscribe@... For more options, visit this group at http://groups.google.com/group/behaviour?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: I'm relativly new to js, can't get this to workoops, bad nesting - for peeps wanting to use this, just nest the bottom 2 functions under the first like so. FUNCTION 1 { FUNCTION 2 {} FUNCTION 2 {} } =/ On Aug 18, 11:58 am, guzguz <codenameguz...@...> wrote: > <script type="text/javascript"> > var W3CDOM = (document.createElement && > document.getElementsByTagName); > > var focusON = new Array(); > var focusOFF = new Array(); > > window.onload = init; > > function init() > { > if (!W3CDOM) return; > var parent = document.getElementById('commentform'); > var child = parent.getElementsByTagName('input'); > for (var i=0;i<child.length;i++) > { > child[i].onfocus = focusON; > child[i].onblur = focusOFF; > } > > } > > function focusON() > { > this.style.borderBottom="1px solid #333"; > > } > > function focusOFF() > { > this.style.borderBottom="1px solid #000";} > > </script> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Behaviour Javascript Library" group. To post to this group, send email to behaviour@... To unsubscribe from this group, send email to behaviour-unsubscribe@... For more options, visit this group at http://groups.google.com/group/behaviour?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: I'm relativly new to js, can't get this to work@Ben - i have heard of prototype.js and have used it on other things, i kinda just wanted to make something quick for IE :focus fix but i spent almost 30 minutes trying to see what was wrong? i mean the logic was correct i guess i just went to fast - I just hate inline js code and i'm not so good in js but thanks for your quick response and your point is taken with them js library's ( prototype.js ) On Aug 18, 12:11 pm, guzguz <codenameguz...@...> wrote: > oops, bad nesting - for peeps wanting to use this, just nest the > bottom 2 functions under the first like so. > > FUNCTION 1 > { > FUNCTION 2 {} > FUNCTION 2 {} > } > > =/ > > On Aug 18, 11:58 am, guzguz <codenameguz...@...> wrote: > > > <script type="text/javascript"> > > var W3CDOM = (document.createElement && > > document.getElementsByTagName); > > > var focusON = new Array(); > > var focusOFF = new Array(); > > > window.onload = init; > > > function init() > > { > > if (!W3CDOM) return; > > var parent = document.getElementById('commentform'); > > var child = parent.getElementsByTagName('input'); > > for (var i=0;i<child.length;i++) > > { > > child[i].onfocus = focusON; > > child[i].onblur = focusOFF; > > } > > > } > > > function focusON() > > { > > this.style.borderBottom="1px solid #333"; > > > } > > > function focusOFF() > > { > > this.style.borderBottom="1px solid #000";} > > > </script> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Behaviour Javascript Library" group. To post to this group, send email to behaviour@... To unsubscribe from this group, send email to behaviour-unsubscribe@... For more options, visit this group at http://groups.google.com/group/behaviour?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: I'm relativly new to js, can't get this to work@Ben - i have heard of prototype.js and have used it on other things, i kinda just wanted to make something quick for IE :focus fix but i spent almost 30 minutes trying to see what was wrong? i mean the logic was correct i guess i just went to fast - I just hate inline js code and i'm not so good in js and i know the code is ugly but like i said i'm not to fond of js so i never really attempt to use it and be efficient in it only when it's necessary i use js but thanks for your quick response and your point is taken with them js library's ( prototype.js ). On Aug 18, 12:10 pm, "Ben Nolan" <bno...@...> wrote: > That is quite atrocious code - but I see what you're trying to do. > > child[i].onfocus = focusON.bind(child[i]); > > will do what you want if you include prototype.js. You should read up on > using prototype properly to do classes and binding and Event.observe - > that'll make your js life a lot happier. :) > > Ben > > On 8/18/07, guzguz <codenameguz...@...> wrote: > > > > > > > <script type="text/javascript"> > > var W3CDOM = (document.createElement && > > document.getElementsByTagName); > > > var focusON = new Array(); > > var focusOFF = new Array(); > > > window.onload = init; > > > function init() > > { > > if (!W3CDOM) return; > > var parent = document.getElementById('commentform'); > > var child = parent.getElementsByTagName('input'); > > for (var i=0;i<child.length;i++) > > { > > child[i].onfocus = focusON; > > child[i].onblur = focusOFF; > > } > > } > > > function focusON() > > { > > this.style.borderBottom="1px solid #333"; > > } > > > function focusOFF() > > { > > this.style.borderBottom="1px solid #000"; > > } > > </script> > > -- > Regards, > Ben Nolan > > http://bennolan.com/ > > skype: bennolan > cell: +49 1577 383 7542 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Behaviour Javascript Library" group. To post to this group, send email to behaviour@... To unsubscribe from this group, send email to behaviour-unsubscribe@... For more options, visit this group at http://groups.google.com/group/behaviour?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |