23. three template columns in the DataGrid contain textbox columns dg_shuliang (Quantity) dg_danjian (unit price) dg_jine (amount) in 5.6.7, respectively, it is required that the amount be calculated automatically when the quantity and unit price are entered: quantity * unit price = amount, and the input time limit must be numeric. how can I use a client script to implement this function?
[Si GUI 〗
<Asp: templatecolumn headertext = "quantity">
<Itemtemplate>
<Asp: textbox id = "shuliang" runat = 'server' text = '<% # databinder. eval (container. dataitem, "dg_shuliang") %>'
OnkeyUp = "javascript: Docal ()"
/>
<Asp: regularexpressionvalidator id = "REVS" runat = "server" controltovalidate = "shuliang" errormessage = "must be integer" validationexpression = "^ d + $"/>
</Itemtemplate>
</ASP: templatecolumn>
<Asp: templatecolumn headertext = "unit price">
<Itemtemplate>
<Asp: textbox id = "danjian" runat = 'server' text = '<% # databinder. eval (container. dataitem, "dg_danjian") %>'
OnkeyUp = "javascript: Docal ()"
/>
<Asp: regularexpressionvalidator id = "revs2" runat = "server" controltovalidate = "danjian" errormessage = "must be numeric" validationexpression = "^ d + (. D *)? $ "/>
</Itemtemplate>
</ASP: templatecolumn>
<Asp: templatecolumn headertext = "amount">
<Itemtemplate>
<Asp: textbox id = "jine" runat = 'server' text = '<% # databinder. eval (container. dataitem, "dg_jine") %>'/>
</Itemtemplate>
</ASP: templatecolumn>
<Script language = "JavaScript">
Function Docal ()
{
VaR E = event. srcelement;
VaR ROW = E. parentnode. parentnode;
VaR txts = row. All. Tags ("input ");
If (! Txts. Length | txts. Length <3)
Return;
VaR q = txts [txts. Length-3]. value;
VaR P = txts [txts. Length-2]. value;
If (isnan (q) | isnan (p ))
Return;
Q = parseint (Q );
P = parsefloat (P );
txts [txts. Length-1]. value = (Q * P). tofixed (2);
}< br>