in code behind :
b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; ");
b.Append("width:80%; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>");
b.Append("<tr><td colspan='9' align ='center' style='background-color:#336699; color:white;'>");
b.Append("<b>Machine Counter</b>");
b.Append("</td></tr>");
b.Append("<td><b>MACHINENAME</b></td>");
b.Append("<td><b>START</b></td>");
b.Append("<td><b>END</b></td>");
b.Append("<td><b>TOTAL_RUNTIME</b></td></tr>");
for (int i = 0; i < newds.Tables[0].Rows.Count; i++)
{
b.Append("<tr>");
b.Append("<td>" + newds.Tables[0].Rows[i]["machinename"].ToString() + "</td>");
if (newds.Tables[0].Rows[i][3].ToString() != "Y")
{
b.Append("<td><input type = 'textbox' READONLY = 'readOnly' id = 'TextBoxRow_" + i + "col_" + 1 + " ' value = '" + newds.Tables[0].Rows[i]["end_counter"].ToString() + "' /></td>");
}
else
{
b.Append("<td><input type = 'textbox' READONLY = 'readOnly' id = 'TextBoxRow_" + i + "col_" + 1 + " ' value = '" + 0 + "' /></td>");
}
b.Append("<td><input type = 'textbox' id = 'TextBoxRow_" + i + "col_" + 2 + " ' value = '" + 0 + "' onkeypress = 'return checkNum(this.id)' onchange = 'return change_text( ("+i+")' /></td>"); // onchange = ' return change_text(" + i + " )'
if (newds.Tables[0].Rows[i][3].ToString() != "Y")
{
b.Append("<td ><input type = 'textbox' READONLY = 'readOnly' id = 'TextBoxRow_" + i + "col_" + 3 + " ' value = '" + newds.Tables[0].Rows[i]["end_counter"].ToString() + "' /></td>");
}
else
{
b.Append("<td ><input type = 'textbox' READONLY = 'readOnly' id = 'TextBoxRow_" + i + "col_" + 3 + " ' value = '" + 0 + "' /></td>");
}
b.Append("</tr>");
}
b.Append("</table>");
java script function in aspx page :
function change_text(i)
{
var txtvalue1 = document.getElementById("TextBoxRow_"+i+"col_1");
var txtvalue2 = document.getElementById("TextBoxRow_"+i+"col_2");
var txtvalue3 = document.getElementById("TextBoxRow_"+i+"col_3").value;
}
problm:
in function onchange = ‘return change_text(this.id )’
i could able to pass the value of textboxrow_icol_2 ,
i need to pass the values of other 2 boxes in the same function textboxrow_icol_1 &
textboxrow_icol_3
how to do it.. please help me out to solve this isue
If I understand you correctly, you only need the onchange on one of your textboxes, but within its handler you want to be able to access the values from three textboxes in the same row?
In your server side code do this:
So that you just pass the row number to your change_text() function. Then in your client-side code do this:
Alternatively you can do
onchange='return change_text(this);', passing the function a reference to the input directly instead of its id or row number, and then define your function something like:EDIT: If you copy and paste my first example it won’t work because I got the capitalisation wrong and left out an underscore for your input id attributes. So where I had
"Col1"it should be"col_1"(and so forth for col_2, col_3).