Skip to main content
added 1092 characters in body
Source Link
  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[{makesoptions}],
    {year, years},
    {make, makes},
    {model, models},
    {option, options},
    TrackedSymbols :> {make, year, model, option}
 ]
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]];
 
    Row[{makes}],
    {year, years},
    {make, makes}
 ]
  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}
 ]
Made English more idiomatic
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

Manipulate with dynamic contentnot updating the way I expected it to

I want to make a selector, wich allow to you that allows me to select first a date and depend of that, depending on the date, load a different makes list, and after that with a combination of both it you cancar 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]];
 
    Row[{makes}],
    {year, years},
    {make, makes}
 ]

The problem is that, when youI change the year, the car makes list changeshould also, but it change; the change shows at rowup in the contents pane, but is not atreflected in the control specified by {make, makes}.

Manipulate with dynamic content

I want to make a selector, wich allow to you to select first a date and depend of that date load a different makes list, and after that with a combination of both it you can select a specific car

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]];
 
    Row[{makes}],
    {year, years},
    {make, makes}
 ]

The problem is that when you change the year the makes list change also, but it shows at row but not at {make, makes}

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]];
 
    Row[{makes}],
    {year, years},
    {make, makes}
 ]

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}.

Source Link

Manipulate with dynamic content

I want to make a selector, wich allow to you to select first a date and depend of that date load a different makes list, and after that with a combination of both it you can select a specific car

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]];
 
    Row[{makes}],
    {year, years},
    {make, makes}
 ]

The problem is that when you change the year the makes list change also, but it shows at row but not at {make, makes}