Hi, Anybody know why :onchange works here... <%= select_tag "Minisections", options_from_collection_for_select(@minisections, :id, :title, :selected => @minisection.id), {:onChange => "{alert(''Minisection has been changed to x !'')}"} %> but NOT here (to call a function)... <script type="text/javascript"> function xyz() { "{alert(''Minisection has been changed to x !'')}"} </script> <%= select_tag "Minisections", options_from_collection_for_select(@minisections, :id, :title, :selected => @minisection.id), {:onChange => "xyz()"} %> The function is at the top of the .html.erb page. I have used a similar format with :onclick and it works fine. Thanks, DC -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Aug 29, 2011, at 8:27 AM, Dave Castellano wrote:> Hi, > > Anybody know why :onchange works here... > <%= select_tag "Minisections", > options_from_collection_for_select > (@minisections, :id, :title, :selected > => @minisection.id), {:onChange => "{alert(''Minisection has been > changed > to x !'')}"} %> > > but NOT here (to call a function)... > <script type="text/javascript"> > function xyz() { > "{alert(''Minisection has been changed to x !'')}"} > </script> > > <%= select_tag "Minisections", > options_from_collection_for_select > (@minisections, :id, :title, :selected > => @minisection.id), > {:onChange => "xyz()"} %> > > The function is at the top of the .html.erb page. I have used a > similar > format with :onclick and it works fine.Visit your rendered page in a browser, view source, and copy all. Then go to http://validator.w3.org and use the Direct Input tab and paste. Validate your page. If it passes there, then enable Firebug in your copy of Firefox, open up the console section, and visit your page. You either have an HTML/DOM error or a JavaScript error. Once you figure out which one you''re dealing with in this case, you can proceed to a fix. Walter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Aug 29, 1:27 pm, Dave Castellano <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > > Anybody know why :onchange works here... > <%= select_tag "Minisections", > options_from_collection_for_select(@minisections, :id, :title, :selected > => @minisection.id), {:onChange => "{alert(''Minisection has been changed > to x !'')}"} %> > > but NOT here (to call a function)... > <script type="text/javascript"> > function xyz() { > "{alert(''Minisection has been changed to x !'')}"} > </script> >Because all that function does is create a string literal - it''s not actually calling alert because all that is enclosed in "". Fred> <%= select_tag "Minisections", > options_from_collection_for_select(@minisections, :id, :title, :selected > => @minisection.id), > {:onChange => "xyz()"} %> > > The function is at the top of the .html.erb page. I have used a similar > format with :onclick and it works fine. > > Thanks, > > DC > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Frederick Cheung wrote in post #1019042:> On Aug 29, 1:27pm, Dave Castellano <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> function xyz() { >> "{alert(''Minisection has been changed to x !'')}"} >> </script> >> > Because all that function does is create a string literal - it''s not > actually calling alert because all that is enclosed in "". > > FredConversely, copying and pasting something found in a rails bastardization of an html element and treating it as javascript code won''t 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks! Working on HTML errors now. Then on to Firebug... DC -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks 7stud, I am trying to learn Rails, HTML, Javascript, and Ajax but am learning on my own. No programming background. I spent a couple of days trying to figure this out before asking the question, and did Google it . Been working on this project for over a year (maybe longer) and have only asked for help a few times. Up till your reply, everyone has been very helpful. DC -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Fred, Can''t believe I made that stupid a mistake! DC -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Heya Dave - do not let the trolls scare you - we are all beginners at some point - asking queations will help you learn and progress. web apps are a complex beast Glad to have you in the community. On Aug 30, 2011 12:44 PM, "Dave Castellano" <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thanks 7stud, > > I am trying to learn Rails, HTML, Javascript, and Ajax but am learning > on my own. No programming background. I spent a couple of days trying > to figure this out before asking the question, and did Google it . Been > working on this project for over a year (maybe longer) and have only > asked for help a few times. Up till your reply, everyone has been very > helpful. > > DC > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email torubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.>-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.