Skip to main content
3 of 3
added 1092 characters in body

Manipulate not updating the way I expected it to

I want to make a selector that allows me to select a date and, depending on the date, load a list of car makes. After that, I should be able to select a specific car make.

  Manipulate[
    years = 
  Import["http://www.fueleconomy.gov/ws/rest/vehicle/menu/year", 
   "XML"];
    y = Cases[years, XMLElement["menuItem", _, _], Infinity] /. 
    XMLElement[_, _, {val_}] ->  val /. 
   XMLElement["menuItem", _, list_] -> list;
    Do[y[[i]] = DeleteDuplicates[y[[i]]], {i, 1, Length[y], 1}];
    years = y[[All, 1]];
 
    makes = 
  Import[StringJoin[
    "http://www.fueleconomy.gov/ws/rest/vehicle/menu/make?year=", 
    ToString@year], "XML"];
    m = Cases[makes, XMLElement["menuItem", _, _], Infinity] /. 
    XMLElement[_, _, {val_}] ->  val /. 
   XMLElement["menuItem", _, list_] -> list;
    Do[m[[i]] = DeleteDuplicates[m[[i]]], {i, 1, Length[m], 1}];
    makes = m[[All, 1]];
 
    models = 
  Import[URLEncode[
    StringJoin[
     "http://www.fueleconomy.gov/ws/rest/vehicle/menu/model?year=", 
     ToString@year, "&make=", ToString@make]], "XML"];
    mo = Cases[models, XMLElement["menuItem", _, _], Infinity] /. 
    XMLElement[_, _, {val_}] ->  val /. 
   XMLElement["menuItem", _, list_] -> list;
    Do[mo[[i]] = DeleteDuplicates[mo[[i]]], {i, 1, Length[mo], 1}];
    models = mo[[All, 1]];
 
    options = 
  Import[URLEncode[
    StringJoin[
     "http://www.fueleconomy.gov/ws/rest/vehicle/menu/options?year=", 
     ToString@year, "&make=", ToString@make, "&model=", 
     ToString@model]], "XML"];
 o = Cases[options, XMLElement["menuItem", _, _], Infinity] /. 
    XMLElement[_, _, {val_}] ->  val /. 
   XMLElement["menuItem", _, list_] -> list;
    Do[o[[i]] = DeleteDuplicates[o[[i]]], {i, 1, Length[o], 1}];
    options = o[[All, 1]];
 
    Row[{options}],
    {year, years},
    {make, makes},
    {model, models},
    {option, options},
    TrackedSymbols :> {make, year, model, option}
 ]

The problem is that, when I change the year, the car makes list should also change; the change shows up in the contents pane, but is not reflected in the control specified by {make, makes}.