2 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
source | link

This is a bit confusing, as there are two threads now with similar content here and in the other thread. Based on my answermy answer, the following code would work for your example:

Clear[list];
    list = {"red", "yellow", "blue"};
    DynamicModule[
     {n1 = 10, colour = "blue"},
     Panel[Grid[{
      {InputField[Dynamic[colour], String],
       Style[Dynamic[Do[If[list[[i]] == colour, n1 = i], {i, 1, 3}]], Transparent]},
       {Dynamic[Plot[Sin[Pi*n1*x], {x, 1, 3}, GridLines -> Automatic, ImageSize -> 300]]}
      }]]
    ]

This is a bit confusing, as there are two threads now with similar content here and in the other thread. Based on my answer, the following code would work for your example:

Clear[list];
    list = {"red", "yellow", "blue"};
    DynamicModule[
     {n1 = 10, colour = "blue"},
     Panel[Grid[{
      {InputField[Dynamic[colour], String],
       Style[Dynamic[Do[If[list[[i]] == colour, n1 = i], {i, 1, 3}]], Transparent]},
       {Dynamic[Plot[Sin[Pi*n1*x], {x, 1, 3}, GridLines -> Automatic, ImageSize -> 300]]}
      }]]
    ]

This is a bit confusing, as there are two threads now with similar content here and in the other thread. Based on my answer, the following code would work for your example:

Clear[list];
    list = {"red", "yellow", "blue"};
    DynamicModule[
     {n1 = 10, colour = "blue"},
     Panel[Grid[{
      {InputField[Dynamic[colour], String],
       Style[Dynamic[Do[If[list[[i]] == colour, n1 = i], {i, 1, 3}]], Transparent]},
       {Dynamic[Plot[Sin[Pi*n1*x], {x, 1, 3}, GridLines -> Automatic, ImageSize -> 300]]}
      }]]
    ]
1
source | link

This is a bit confusing, as there are two threads now with similar content here and in the other thread. Based on my answer, the following code would work for your example:

Clear[list];
    list = {"red", "yellow", "blue"};
    DynamicModule[
     {n1 = 10, colour = "blue"},
     Panel[Grid[{
      {InputField[Dynamic[colour], String],
       Style[Dynamic[Do[If[list[[i]] == colour, n1 = i], {i, 1, 3}]], Transparent]},
       {Dynamic[Plot[Sin[Pi*n1*x], {x, 1, 3}, GridLines -> Automatic, ImageSize -> 300]]}
      }]]
    ]