Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I make a function name as IncrementInputFieldsCreation.

  (*Option*)
  Options[IncrementInputFieldsCreation]:={partion->All,rowsInputFields-> 1};
  (*Defination*)
 IncrementInputFieldsCreation[noOfInputFields_,OptionsPattern[]]:=
  (
   Module[{inputvaluelist=Null},
         (*it checks wheather noOfInputFields value is 0 or not*)
        If[
    (noOfInputFields>0),
    (*If noOfInputFields value is greater than 0*)
    (inputvaluelist=Table[0,{noOfInputFields},{OptionValue[rowsInputFields]}];
    (*output*)
    output={
            Table[
                 (
                    With[{i=i,j=j},
                        (Row[{
                            Column[{
                                    MouseAppearance[
                                                    EventHandler[
                                                                Style["\[FilledUpTriangle]",Bold,Black,{15,15}],
                                                                {"MouseClicked":>(inputvaluelist[[i,j]]=inputvaluelist[[i,j]]+1)}
                                                                ],
                                                    "LinkHand"
                                                    ],
                                    MouseAppearance[
                                                    EventHandler[
                                                                Style["\[FilledDownTriangle]",Bold,Black,{15,15}],(*Button Next to InputField For Decrement *)
                                                                {"MouseClicked":>(If[
                                                                                    (inputvaluelist[[i,j]]>0),
                                                                                    (inputvaluelist[[i,j]]=inputvaluelist[[i,j]]-1),
                                                                                    (inputvaluelist[[i,j]]=0)
                                                                                    ]
                                                                                 )
                                                                }
                                                               ],
                                                    "LinkHand"
                                                  ]
                                    },
                                    Spacings->0,
                                    Alignment->Center,
                                    Background->RGBColor[0.65,0.65,0.65]
                                ],
                        InputField[
                                    Dynamic[inputvaluelist[[i,j]]],
                                    Number,
                                    ContinuousAction->True,
                                    ImageSize->{50,20},
                                    Alignment->Center
                                  ]
                        }](*Row is closed here*)
                     )
                    ]
                    (*with is closed*)
                   ),
                    {i,1,Length[inputvaluelist]},
                    {j,1,Length[Part[inputvaluelist,i]]}
            ],(*Table closed*)
            Dynamic[inputvaluelist]
        };
    Part[output,OptionValue[partion]]
    ),
    ("")
  ](*If Closed here*)
](*Module closed*)
  )

case1:

IncrementInputFields`IncrementInputFieldsCreation[3,rowsInputFields -> 4]

If you call that function in the above way,we will get list of InputFields and InputFieldValues. and also if you can click on upArrowbutton (beside of the InputField) the value of the InputField will be increased like that in opposite way downArrowbutton will work..

case2:

value = 1;
{PopupMenu[Dynamic[value], Range[6]], 
  Dynamic[IncrementInputFields`IncrementInputFieldsCreation[value, 
   rowsInputFields -> 4]]} 

in case2, dynamically we will get list of InputFields and InputFieldValuesdepending upon the PopupMenu value.

but problem is,dynamically the upArrow,downArrow buttons are not working...

I think in case2,dynamically function is evaluated everytime so because of that it's not working..

how can I overcome this?

share|improve this question
Did you try Setting? – PlatoManiac Jan 22 at 18:21
sorry I don't know what Setting? – subbu Jan 22 at 18:27
1  
Check the documentation for it. It helps you to retrieve value stored in a Dynamic variable. In your above code why dont you use DynamicModule in place of Module? – PlatoManiac Jan 22 at 18:32
I tried with DynamicModule also ,still not get it.. – subbu Jan 22 at 18:37
1  
If you change Module to DynamicModule and remove the context name IncrementInputFields from the function name you get something that works as expected in Version 9 (MS Vista 64bit). – kguler Jan 22 at 19:55
show 3 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.