harrison
|
分享:
x0
|
[JScript][讨论] 烦请高手帮我解答一下~
呼叫函数时并传入参数值 如 myScore("May","90","100") 不是都要用引号吗? 但我看到的这个 Avg=myAvg("May","90","100") 用引号反而出不来~ 请高手解答一下~谢谢^^ (一)<html> <head> <title>有传入参数的函数</title> <script language="JavaScript"> <!-- function myScore(stu_Name,stu_Math,stu_Eng) { //定义myScore函数,并设定3个参数 document.write("<tr><td>学生姓名:"+stu_Name+"</td><td>数学成绩:"+stu_Math+"</td><td>英文成绩:"+stu_Eng+"</td></tr>"); } //--> </script> </head> <body> <center> <font face="Arial Black" color="#CC3300" size="3"> <img src="images/9.jpg" width="150"> <table width="100%"> <script language="JavaScript"> <!-- myScore("Eileen","90","100"); //呼叫myScore函数并传入3个参数 myScore("Jennifer","60"); //呼叫myScore函数并传入2个参数值 myScore("May","70","90","100"); //呼叫myScore函数并传入4个参数值 //--> </script> </table> </font> </center> </body> </html> (二) <html> <head> <title>传回值的函数</title> <script language="JavaScript"> <!-- function myAvg(stu_Name,stu_Math,stu_Eng) { //定义myAvg函数,并设定3个参数 stu_Avg=(stu_Math+stu_Eng)/2; return(stu_Avg); //传回stu_Avg变数的值 } //--> </script> </head> <body> <center> <font face="Arial Black" color="#CC3300" size="3"> <img src="images/9.jpg" width="150"> <table width="100%"> <tr><td>学生姓名:<font face="Arial Black" color="#CC3300" size="3">Eileen</font></td><td>数学成绩:<font face="Arial Black" color="#CC3300" size="3">90</font></td><td>英文成绩:<font face="Arial Black" color="#CC3300" size="3">100</font></td></tr><tr><td colspan=3> <script language="JavaScript"> <!-- //呼叫myAvg函数并传入3个参数,stu_Avg变数接收传回的值 Avg=myAvg("Eileen",90,100); document.write("平均成绩:"+Avg); //--> </script> </td></tr> </table> </font> </center> </body> </html>
|