WebbedIT
2007-Aug-31 14:33 UTC
Ajax.Updater on a select list not updating correctly in IE7 (fine in FireFox)
Hi all, Been working with prototype and script.aculo.us now for around 3 days after never really touching javascript so I am still getting to grips with things. So far I have successfully created 4 ajax based functions, or so I thought until I stupidly showed a client one of them before I had tested it in IE. The function in question works fine in FireFox succesfully inserting any new values into the dbase, then refereshing the select list to include the new value and selecting that value. In IE7 the call to the PHP script works as the new region gets added to the dbase, but the Select List (region container) get''s emptied of all options. Code is as follows, any solutions would be gratefully accepted :o) Paul. <<< HTML >>>>>>>>>>>>>>>>>>>> <dl> <dt><label for="region">Region</label></dt> <dd><select id="region" name="scheme[region]" size="1" onchange="scheme.changeRegion(this)"> <option value="67" >East England</option> <option value="64" >East Midlands</option> <option value="70" >Isle of Man</option> <option value="61" >North East</option> <option value="new">New region ...</option> </select></dd> </dl> <<< JavaSript >>>>>>>>>>>>>>>>>>>> var scheme = { changeRegion: function(element) { if ($F(element) != "new") return; if (scheme.createRegion(element)) { } else { element.down("option").selected = true; } }, createRegion: function(element) { var name; if (name = prompt("New region name:")) { new Ajax.Updater(''region'', ''/schemeapp/schemeAjax'', { method:''get'', parameters: {action: ''createRegion'', name: name} }); return true; } else { return false; } } } <<< PHP >>>>>>>>>>>>>>>>>>>> qry = "check if a region exists with same name"; if (region does not exist) { qry = "insert new region into db"; } qry = "select all regions in alphabetical order" while (regionsexist) { echo "<option value="id" ".(newregion == existingregion ? '' selected="selected"'' : '''').">existingregion </option>"; } echo "<option value="new">New region ...</option>"; --~--~---------~--~----~------------~-------~--~----~ 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-Aug-31 15:13 UTC
Re: Ajax.Updater on a select list not updating correctly in IE7 (fine in FireFox)
ah, i believe that''s because FF is smarter than IE. try giving the DD tag the id="region" and on the back side rebuild the entire Select list and returning that. Then you only need to worry about safari 3 crashing; but on the upside nearly everything else should work right. On 8/31/07, WebbedIT <paul-BKqkkOijtfm9FHfhHBbuYA@public.gmane.org> wrote:> > > Hi all, > > Been working with prototype and script.aculo.us now for around 3 days > after never really touching javascript so I am still getting to grips > with things. > > So far I have successfully created 4 ajax based functions, or so I > thought until I stupidly showed a client one of them before I had > tested it in IE. > > The function in question works fine in FireFox succesfully inserting > any new values into the dbase, then refereshing the select list to > include the new value and selecting that value. > > In IE7 the call to the PHP script works as the new region gets added > to the dbase, but the Select List (region container) get''s emptied of > all options. > > Code is as follows, any solutions would be gratefully accepted :o) > > Paul. > > <<< HTML >>>>>>>>>>>>>>>>>>>> > > <dl> > <dt><label for="region">Region</label></dt> > <dd><select id="region" name="scheme[region]" size="1" > onchange="scheme.changeRegion(this)"> > <option value="67" >East England</option> > <option value="64" >East Midlands</option> > <option value="70" >Isle of Man</option> > <option value="61" >North East</option> > <option value="new">New region ...</option> > </select></dd> > </dl> > > <<< JavaSript >>>>>>>>>>>>>>>>>>>> > > var scheme = { > changeRegion: function(element) { > if ($F(element) != "new") return; > if (scheme.createRegion(element)) { > > } else { > element.down("option").selected = true; > } > }, > > createRegion: function(element) { > var name; > if (name = prompt("New region name:")) { > new Ajax.Updater(''region'', ''/schemeapp/schemeAjax'', { > method:''get'', > parameters: {action: ''createRegion'', name: name} > }); > return true; > } else { > return false; > } > } > } > > <<< PHP >>>>>>>>>>>>>>>>>>>> > > qry = "check if a region exists with same name"; > if (region does not exist) { > qry = "insert new region into db"; > } > qry = "select all regions in alphabetical order" > while (regionsexist) { > echo "<option value="id" ".(newregion == existingregion ? '' > selected="selected"'' : '''').">existingregion </option>"; > } > echo "<option value="new">New region ...</option>"; > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
WebbedIT
2007-Aug-31 16:17 UTC
Re: Ajax.Updater on a select list not updating correctly in IE7 (fine in FireFox)
> try giving the DD tag the id="region" and on the back side rebuild the > entire Select list and returning that.Yeay! {WebbedIT dances a little ''IE is still a poor imitation of FireFox dance''} I am now taking a moment for the completion of my first IE hack/ workaround in a new programming environment. I am sure there will be many more to come. Thanks for the heads up ... maded the adjustment and it tested just fine. Paul (WebbedIT). --~--~---------~--~----~------------~-------~--~----~ 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-Aug-31 17:36 UTC
Re: Ajax.Updater on a select list not updating correctly in IE7 (fine in FireFox)
no sweat, i started looking into it and found the solution was to use a bunch of js to find the select then createElement then appendElement and was like, forget it, thats too much work for the browser to screw up and decided it would be quicker and cheaper and more worry free to just rebuild the entire list. On 8/31/07, WebbedIT <paul-BKqkkOijtfm9FHfhHBbuYA@public.gmane.org> wrote:> > > > > try giving the DD tag the id="region" and on the back side rebuild the > > entire Select list and returning that. > > Yeay! {WebbedIT dances a little ''IE is still a poor imitation of > FireFox dance''} > > I am now taking a moment for the completion of my first IE hack/ > workaround in a new programming environment. I am sure there will be > many more to come. > > Thanks for the heads up ... maded the adjustment and it tested just > fine. > > Paul (WebbedIT). > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---