PDA

View Full Version : Concatenating a string to a variable


codefox
12-11-2002, 05:02 AM
I have a function called calculateCategoryAvg(sCat) with sCat as a parameter. Later in the function I would like to concatenate the value in sCat with txtAvg which is a text box in a form. For example, if sCat has the value "Q", then
frmCustFeedback.txtAvgQ.value = "Poor";
If if sCat has the value "C", then
frmCustFeedback.txtAvgC.value = "Poor";
How could I concatenate the value of sCat with txtAvg.

Thanks.

glenngv
12-11-2002, 05:10 AM
frmCustFeedback.elements["txtAvg"+sCat].value = "Poor";

codefox
12-11-2002, 05:56 AM
Thanks. That works. I was trying to do that using eval() but since yours worked I gave up eval() :)