Programme
2007-Jun-06 15:50 UTC
Getting ajax to update a select box after php mysql script is run.
Hi I''ll get to it right away: 1. I have a simple page with a form, in this form there is a "select" box with a number of options. On the right i also have a "input" field with a submit option. 2. When the user puts something in the input field and hits submit, a php script is run, that puts that entry in mysql table. Question: 3. How do i with Ajax update the "select" box, so that the user can see the last entry there. Yes i want to use Ajax so that only the "select" box is updated, the rest of the page and form stays as it is. I have read on new ajax.updater and onComplete, onSuccess and so on using prototype, but have not yet figured it out, hope there is someone that can help. Programme --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Brian Williams
2007-Jun-06 16:13 UTC
Re: Getting ajax to update a select box after php mysql script is run.
have the php script return a rebuilt select box with the new entry. I would say use plain JS to add the entry to the select box - but i would think you would want to verify that the input into the database actually succeeded. On 6/6/07, Programme <ejmyrvang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi > > I''ll get to it right away: > > 1. I have a simple page with a form, in this form there is a "select" > box with a number of options. On the right i also have a "input" field > with a submit option. > > 2. When the user puts something in the input field and hits submit, a > php script is run, that puts that entry in mysql table. > > Question: > > 3. How do i with Ajax update the "select" box, so that the user can > see the last entry there. > > Yes i want to use Ajax so that only the "select" box is updated, the > rest of the page and form stays as it is. I have read on new > ajax.updater and onComplete, onSuccess and so on using prototype, but > have not yet figured it out, hope there is someone that can help. > > Programme > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Alex Duffield
2007-Jun-06 19:18 UTC
Re: Getting ajax to update a select box after php mysql script is run.
Here are some functions I wrote for dealing with select boxes... function setSelectByValue(id, v){ var o = $(id).options; for (var index = 0; index < o.length; ++index) { var item = o[index]; if(v == item.value){ s.options.selectedIndex = index; return true } } return false } function setSelectByText(id, t){ var o = $(id).options; for (var index = 0; index < o.length; ++index) { var item = o[index]; if(t == item.text){ s.options.selectedIndex = index; return true } } return false } function removeOption(id, v){ if(v == "all"){ // Remove all options $(id).options.length = 0; return true; } // remove options with matching value. var o = $(id).options; for (var index = 0; index < o.length; ++index) { var item = o[index]; if(v == item.value){ o[index] = null; return true } } return false } function addSelectOption(id,t,v ){ var optn = document.createElement("OPTION"); optn.text = t; optn.value = v; $(id).options.add(optn); } ______________________________________________________________________ Alex Duffield ❖ Principal ❖ InControl Solutions . http:// www.incontrolsolutions.com On 6-Jun-07, at 8:50 AM, Programme wrote:> > Hi > > I''ll get to it right away: > > 1. I have a simple page with a form, in this form there is a "select" > box with a number of options. On the right i also have a "input" field > with a submit option. > > 2. When the user puts something in the input field and hits submit, a > php script is run, that puts that entry in mysql table. > > Question: > > 3. How do i with Ajax update the "select" box, so that the user can > see the last entry there. > > Yes i want to use Ajax so that only the "select" box is updated, the > rest of the page and form stays as it is. I have read on new > ajax.updater and onComplete, onSuccess and so on using prototype, but > have not yet figured it out, hope there is someone that can help. > > Programme > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Seemingly Similar Threads
- Ajax.Request synchronization (onSuccess before onComplete?)
- Ajax.InPlaceEditor onSuccess: ???
- RE: [Prototype] onSuccess Event and, Ajax.Updater bug in IE
- [Prototype] onSuccess Event and Ajax.Updater bug in IE
- Ajax.Updater not populating element - please help