日期:2014-05-17  浏览次数:21042 次

asp-javascript传递数值
这个相互传递数值的没涉及过,请大家给出错误和解决方法.
通过修改str的值,然后点击按钮,能够输出不同结果.

<%
Dim   str    
str=2006
Response.Write   (str)
%>

<%
Response.Write   " <script       language=javascript>     "
Response.Write   "     function       send(a)       "
Response.Write   "     {       "
Response.Write   "switch(a)   "
Response.Write   "{   "
Response.Write   "         case   2007   :   "
Response.Write   "     text=document.all.hello1.value;       "
Response.Write   (text)
Response.Write   "     break; "
Response.Write   "         case   2008   :   "
Response.Write   "     text=document.all.hello2.value;       "
Response.Write   (text)
Response.Write   "     break; "
Response.Write   "     }       "
Response.Write   "     }       "
Response.Write   "     </script>       "
Response.Write   " <input   name=button   type=submit   onclick=send(str)   value= 'send   '>       "
Response.Write   " <textarea   name= 'hello1 '   >   welcome   </textarea>       "
Response.Write   " <textarea   name= 'hello2 '   >   thank   </textarea>       "
%>

------解决方案--------------------
<%Dim str
str=2007
Response.Write (str)

Response.Write " <script language=javascript> "
Response.Write " function send(a) "
Response.Write " { "
Response.Write "switch(a) "
Response.Write "{ "
Response.Write " case 2007 : "
Response.Write " text=document.all.hello1.value; "
Response.Write " break; "
Response.Write " case 2008 : "
Response.Write " text=document.all.hello2.value; "
Response.Write " break; "
Response.Write " } "
Response.Write "document.writeln(text); "
Response.Write " } "
Response.Write " </script> "
Response.Write " <input name=button type=submit onclick=send( "&str& ") value= 'send '> "
Response.Write " <textarea name= 'hello1 ' > welcome </textarea> "
Response.Write " <textarea name= 'hello2 ' > thank </textarea> "
%>

------解决方案--------------------
<%
Dim str
str=2006
Response.Write (str)
%>


<script language=javascript>
function send(a)
{
switch(a)
{
case 2007 :
text=document.all.hello1.value;
(text)
break;
case 2008 :
text=document.all.hello2.value;
(text)
break;
}
}
</script>