I want to calculate the price, and if the user checks any checkbox then the value in the corresponding hidden text box is to be added and displayed on the same page before submitting the page,

I do not want to use the hard coded names of text and check boxex because they are dynamically geneated and may differ in number.

I'm generating the check box and text box name by concating the number at the end of string "chkMouse" (used for check box) and string "txtbox" (used for text box).

When i'm displaying the name in alert it seems ok, but when trying to access the value of the text box using that name , it gives an error,

The JS code is attached please help....

function ug() {
  var i = 1;
  var chkBox;
  var txtBox;

  while(i <= document.forms["test"].txtMouse.value) {
    chkBox = new String("chkMouse"+i);
	txtBox = new String("txtMouse"+i);
	  alert("Checked"+ document.forms["test"].txtBox.value);
	 alert("UnChecked ");
  //var grossValue = document.forms["test"].h_one.value;

  //document.forms["test"].out_one.value = grossValue;