0
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?

1 Answer 1

1

The single/double quotes for tmptext are all wrong.

Sign up to request clarification or add additional context in comments.

1 Comment

The JS does work if i just put alert n it means all is working ,,,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.