onclick="if(this.style.background=''#F9CF00'')this.style.background=''#ffffff'' else this.style.background=''#F9CF00''; How do I implement a conditional if else statement in the onclick? The <tr> is white by default, when a user clicks it, and it is white, I want it to change to orange. And vice versa, Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> onclick > ="if(this.style.background=''#F9CF00'')this.style.background=''#ffffff'' > else this.style.background=''#F9CF00''; > > How do I implement a conditional if else statement in the onclick? > > The <tr> is white by default, when a user clicks it, and it is > white, I > want it to change to orange. And vice versa,this.style.background = (this.style.background == ''#f9cf00'' ? ''#fffff'' : ''#f9cf00'') That last part works like this: (some expression yielding true of false ? return this if true : return this if false) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
onclick="this.style.background=(this.style.background == ''#F9CF00'' ? ''red'' : ''#F9CF00''); Doesn''t seem to work =( -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think there was a simple typo - onclick="this.style.background = (this.style.background == ''#F9CF00'')? ''#FF0000'' : ''#F9CF00'';" You may also want to look into attaching this behind the scenes removing your behavior from your display completely, best practice - but that''s just the geek in me. On Jul 14, 10:17 pm, Justin To <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> onclick="this.style.background=(this.style.background == ''#F9CF00'' ? > ''red'' : ''#F9CF00''); > > Doesn''t seem to work =( > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeff.Corcoran wrote:> I think there was a simple typo - > > onclick="this.style.background = (this.style.background == ''#F9CF00'')? > ''#FF0000'' : ''#F9CF00'';"Not working D> > You may also want to look into attaching this behind the scenes > removing your behavior from your display completely, best practice - > but that''s just the geek in me. > > On Jul 14, 10:17�pm, Justin To <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Yah, once I get it to work I''ll stick it somewhere else =) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Try this: onclick="style.backgroundColor=(style.backgroundColor =''rgb(249, 207, 0)'' ? ''#FF0000'' : ''#F9CF00'')" Even when you assign a string like ''#ffffff'' internally is converted to ''rgb(255, 255, 255)'' Works for me in Firefox 3.0 and Safari 3.1.2 Regards. On 14 jul, 20:08, Justin To <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> onclick="if(this.style.background=''#F9CF00'')this.style.background=''#ffffff'' > else this.style.background=''#F9CF00''; > > How do I implement a conditional if else statement in the onclick? > > The <tr> is white by default, when a user clicks it, and it is white, I > want it to change to orange. And vice versa, > > Thanks > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If that is still not working - can you drop an example of the code and an error? The above example I gave you worked for me. On Jul 14, 11:42 pm, Franco Catena <francocat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try this: onclick="style.backgroundColor=(style.backgroundColor => ''rgb(249, 207, 0)'' ? ''#FF0000'' : ''#F9CF00'')" > > Even when you assign a string like ''#ffffff'' internally is converted > to ''rgb(255, 255, 255)'' > > Works for me in Firefox 3.0 and Safari 3.1.2 > > Regards. > > On 14 jul, 20:08, Justin To <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > onclick="if(this.style.background=''#F9CF00'')this.style.background=''#ffffff'' > > else this.style.background=''#F9CF00''; > > > How do I implement a conditional if else statement in the onclick? > > > The <tr> is white by default, when a user clicks it, and it is white, I > > want it to change to orange. And vice versa, > > > Thanks > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeff.Corcoran wrote:> If that is still not working - can you drop an example of the code and > an error? The above example I gave you worked for me.Jeff, it works great in Firefox 3.0, but not in IE 7, any suggestions on that? Thanks!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Also, I have onclick Element.show(''<%= user.email -%>'') => show <tr> How do I apply the same logic as the bg color to say, "<tr> is showing, so onlcick hide it, and vice versa": Element.hide(''<%= user.email -%> Thanks!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you can give me an example of the HTML that is coming out I may be able to help you better. On Jul 15, 10:53 am, Justin To <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Also, I have > > onclick > Element.show(''<%= user.email -%>'') > => show <tr> > > How do I apply the same logic as the bg color to say, "<tr> is showing, > so onlcick hide it, and vice versa": > > Element.hide(''<%= user.email -%> > > Thanks!! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeff.Corcoran wrote:> If you can give me an example of the HTML that is coming out I may be > able to help you better. > > On Jul 15, 10:53�am, Justin To <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>How do I get that? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Justin To wrote:> > How do I get that?Just look at the source and then cut and paste -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
But there is no source for that since it''s using ajax w/o refreshing the page. It shows the table, but the source does not reflect the contents -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Use firefox. Select the generated html and right click. There is an option for "Show Selection Source" Or, you can get firebug and either inspect the element or see what the ajax request returned On Tue, Jul 15, 2008 at 4:47 PM, Justin To <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > But there is no source for that since it''s using ajax w/o refreshing the > page. It shows the table, but the source does not reflect the contents > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ixquic696969-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jul-16 11:19 UTC
Re: conditional javascript
Element.show(''<%= user.email -%>'') means that user.email is the id of the tr you want to hide, right? Like this: <tr id=''<%= user.email %>''> .... </tr> (which fails btw. if two users on that page have the same email) Use toggle: <span onclick=''Element.toggle(<%= user.email %>)''>Show/hide it!</ span> Of course you can''t put that into the tr itself because there''s no clicking on something invisible. On Jul 15, 4:53 pm, Justin To <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Also, I have > > onclick > Element.show(''<%= user.email -%>'') > => show <tr> > > How do I apply the same logic as the bg color to say, "<tr> is showing, > so onlcick hide it, and vice versa": > > Element.hide(''<%= user.email -%> > > Thanks!! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ixquic696969-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jul-16 11:24 UTC
Re: conditional javascript
Oops, forgot the quotes <span onclick=''Element.toggle("<%= user.email %>")''>Show/hide it!</ span> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ixquic696969-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Oops, forgot the quotes > > � <span onclick=''Element.toggle("<%= user.email %>")''>Show/hide it!</ > span>Exactly what I was looking for...works like a charm!! Thanks so much! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---