Tan Sarkar 0 Newbie Poster

I dynamically create text box with java script and post the value in next page by IE but when i use mozila or google chrome it does not work.
The script is as follows

function addRowToTable()
{

var tbl = document.getElementById("tblSample");
var lastRow = tbl.rows.length;
document.inp_form.total.value= lastRow;

var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// number_count cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);

// item_name cell
var item_name = row.insertCell(1);
var element1 = document.createElement("input");
element1.type = "text";
element1.readOnly ="yes";
element1.name = "item_name_" + iteration;
element1.id = "item_name_" + iteration;
element1.size = 30;
element1.value=document.inp_form.i_name.value;
item_name.appendChild(element1);

//quantity_size cell
var quantity_size = row.insertCell(2);
var element2 = document.createElement("input");
element2.type = "text";
element2.readOnly ="yes";
element2.name = "quantity_size_" + iteration;
element2.id = "quantity_size_" + iteration;
element2.size = 10;
element2.value=document.inp_form.Q_name.value;
quantity_size.appendChild(element2);

}

the field name genarate as item_name_1, item_name_2 and so on, in IE i post that value and also insert the value in mysql table but it does not work mozila as well as chrome.

The error message is "Notice: Undefined index item_name_1 ..path.. on line ..line no.."

Please help me. i could not understand where is the error or my fault.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.