I''m new to Prototype, and until now, it''s been pretty straightforward. However, I''m getting a wierd value response from $F() when used with <select>. Here''s some stripped down example code (live at http://www.prebeltway.org/test.html): <!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=ISO-8859-1" /> <title>Strange Behavior from $F()</title> <script src=''http://www.prebeltway.org/prototype.js'' type=''text/ javascript'' language=''Javascript''></script> <script src=''http://www.prebeltway.org/ajax.js'' type=''text/ javascript'' language=''Javascript''></script> <link href=''http://www.prebeltway.org/style.css'' rel=''stylesheet'' type=''text/css'' /> </head> <body> <div class=''input'' id=''inputdisplayphone1'' style=''width: 200px;''> <form action=''updateDB'' name=''frmdisplayphone1''> <select id=''selectdisplayphone1'' name=''selectdisplayphone1''> <option value=''Yes'' selected=''selected''>Yes</option> <option value=''No''>No</option> </select> </form> <script type=''text/javascript'' language=''Javascript''> var displayphone1value = $F("selectdisplayphone1"); </script> <img alt='' '' class=''editbutton'' onclick=''alert("value="+displayphone1value)'' src=''editbutton.jpg''/> </div> </body> </html> When you click the red button, the value of selected value should display in an alert. However, it continues to give me the value ''Yes'' regardless of what I select. Any ideas? Thanks in advance! --Josh --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
by the way, I''m using the latest release of prototype --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Josh, Try: var displayphone1value = $F("selectdisplayphone1").value; That should give you the value of the select. On 8/9/07, Josh C <josh-LE8aq9gSDEq61VtY7fu8aA@public.gmane.org> wrote:> > by the way, I''m using the latest release of prototype > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Replacing onclick=''alert("value="+displayphone1value) with onclick=''alert("value="+$F("selectdisplayphone1")) will produce the output you''re looking for. The problem is that in your original code "var displayphone1value $F("selectdisplayphone1");" is only evaluated once at page load time, not every time the event handler is called. Tom On Aug 9, 2:44 pm, Josh C <j...-LE8aq9gSDEq61VtY7fu8aA@public.gmane.org> wrote:> by the way, I''m using the latest release of prototype--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you! That did it! Dumb error. --Josh On Aug 9, 2007, at 7:14 PM, Tom wrote:> > Replacing onclick=''alert("value="+displayphone1value) with > onclick=''alert("value="+$F("selectdisplayphone1")) will produce the > output you''re looking for. > The problem is that in your original code "var displayphone1value > $F("selectdisplayphone1");" is only evaluated once at page load time, > not every time the event handler is called. > > Tom > > > On Aug 9, 2:44 pm, Josh C <j...-LE8aq9gSDEq61VtY7fu8aA@public.gmane.org> wrote: >> by the way, I''m using the latest release of prototype > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---