【发布时间】:2015-10-02 03:08:37
【问题描述】:
Sceneario:
我在WebBrowser 控件中制作自定义html,基本上是输入学生分数。在用户输入数字时的总分列上,应自动填充下一列中的等级,假设现在得分高于 50,则等级 = A,否则等级 = F。
My Code:
这就是我制作 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);
}
和 Javascript 功能:
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) 工作,然后我得到错误。 这不起作用,我收到错误弹出窗口、值为 null 或未定义等。
如果我只是做alert('abc'); 我会看到警报。
任何建议我在这里缺少什么?
【问题讨论】:
标签: javascript c# winforms visual-studio-2012 webbrowser-control