Creating Dynamic table with checkbox values on web

I am trying to create dynamic table with check box on web. The below code works fine for new document . If value exist in “ExistValue” field , Newval is returning empty.

Is something wrong in the code?.

view := “viewKeywords”;

key := "ProductK

trtmp := “”;ey";

tmp:= @DbLookup(“”;“”;view; key;2);

newval := “”;

tdtmp := “”;

cols := 2;

@If(ExistValues = “”;

@If(@IsError(tmp);@Text(tmp);

@For(x := 1; x <= @Elements(tmp); x := x + 1;

		newval := @Text(newval) + @If(x=cols+1 | (x > cols & @Modulo(x+1;cols) = 0); trtmp; "") + tdtmp+ "<input style = \"font-size: 8pt\" name='Productname'"+@If(!@IsDocBeingEdited;" disabled=\"true\"";" ")+ @If(@Contains(Productname;tmp[x]);"CHECKED";"")+" type='checkbox' value='" + tmp[x]+"'>"+ tmp[x] + "</td>"));newval = Productname);

“

” + newval + “
”

Thanks

Mark