Sceneario:
I am making custom html in a WebBrowser control basically it is to enter student marks . On a column Total score when user enters number in it the grade in next column should be automatically populated, assuming for now score above 50 then grade = A , else grade = F.
My Code:
This is how i am making html :
for (int i = 0; i < studentData.Tables[0].Rows.Count; i++)
{
string fullname = studentData.Tables[0].Rows[i]["first name"].ToString().ToUpper() + " " + studentData.Tables[0].Rows[i]["surname"].ToString().ToUpper() + " " + studentData.Tables[0].Rows[i]["Other name"].ToString().ToUpper();
string studentNumber = studentData.Tables[0].Rows[i]["studentformnum"].ToString().ToUpper();
string tmptxt = string.Empty;
tmptxt = "<tr class=\"records\"><td><input onchange=\"doit('score" + i + "','grade_" + i + "')\" ";
tmptxt += "id=\"totalScore\" id=\"score" + i + "\" style=\"text-align:center\" type=\"text\" /></td>";
tmptxt += "<td><input id=\"grade_" + i + "\" style=\"text-align:center\" type=\"text\" /></td><td></td></tr>";
sb.Append(tmptxt);
}
And Javascript Funtion:
content = content.Replace("{JAVASCRIPT}", "<script type='text/javascript'>function doit(tag,tag2)
{ alert(tag); var score= document.getElementById(tag).value; alert(score);}</script>");
alert(tag) works then i get error. This Does not work i get error popup , value null or undefined etc..
If i just do alert('abc'); i see alert .
Any suggestion what i am missing here?