同一文件的两个JS函数之间如何传变量?
同一个页面的两个JS涵数代码,setindex_left_right()里如何获取change_mystyle(my)中的变量style_key<scriptlangua...
同一个页面的两个JS涵数代码,setindex_left_right() 里如何获取change_mystyle(my)中的变量style_key
<script language="javascript">
function change_mystyle(my){
var style_key=my.options[my.selectedIndex].value;
if(style_key == '114la'){
document.getElementById('shoostyleicon').src='$Murl/images/114la/115.gif';
}
}
</script>
<script language="javascript">
function setindex_left_right()
{
var mod_left =document.getElementById("index_left");
var mod_right =document.getElementById("index_right");
for( var i=0;i<mod_left.options.length;i++){
mod_left.options[i].selected=" selected";
}
for( var j=0;j<mod_right.options.length;j++){
mod_right.options[j].selected=" selected";
}
}
</script>
<form action="?" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="setindex_left_right();">
<table>
<tr>
<td>
<select name='mszfg_style' onchange="change_mystyle(this);">
<option value='114la'>114啦风格</option>
<option value='2345' selected>2345导航</option>
<option value='default'>官方风格</option>
<option value='hao123'>好123</option>
</select> 展开
<script language="javascript">
function change_mystyle(my){
var style_key=my.options[my.selectedIndex].value;
if(style_key == '114la'){
document.getElementById('shoostyleicon').src='$Murl/images/114la/115.gif';
}
}
</script>
<script language="javascript">
function setindex_left_right()
{
var mod_left =document.getElementById("index_left");
var mod_right =document.getElementById("index_right");
for( var i=0;i<mod_left.options.length;i++){
mod_left.options[i].selected=" selected";
}
for( var j=0;j<mod_right.options.length;j++){
mod_right.options[j].selected=" selected";
}
}
</script>
<form action="?" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="setindex_left_right();">
<table>
<tr>
<td>
<select name='mszfg_style' onchange="change_mystyle(this);">
<option value='114la'>114啦风格</option>
<option value='2345' selected>2345导航</option>
<option value='default'>官方风格</option>
<option value='hao123'>好123</option>
</select> 展开
2个回答
展开全部
js是在客户端执行的,asp是在服务器端执行的;
asp要想使用客户端js的变量只能通过form方式或url方式回传给asp页面,比如用Ajax;
如果让js在服务端执行(runat='server'),那么asp就可以直接调用了,比如
<script language='javascript' type='text/javascript' runat='server'>
function getDecodeCoordinate(str)
</script>
<%decodelat = getDecodeCoordinate(y2)%>
asp要想使用客户端js的变量只能通过form方式或url方式回传给asp页面,比如用Ajax;
如果让js在服务端执行(runat='server'),那么asp就可以直接调用了,比如
<script language='javascript' type='text/javascript' runat='server'>
function getDecodeCoordinate(str)
</script>
<%decodelat = getDecodeCoordinate(y2)%>
展开全部
定义成全局变量就可以了
<script language="javascript">
var style_key;
function change_mystyle(my){
style_key=my.options[my.selectedIndex].value;
if(style_key == '114la'){
document.getElementById('shoostyleicon').src='$Murl/images/114la/115.gif';
}
}
</script>
<script language="javascript">
function setindex_left_right(){
var mod_left =document.getElementById("index_left");
var mod_right =document.getElementById("index_right");
for( var i=0;i<mod_left.options.length;i++){
mod_left.options[i].selected=" selected";
}
for( var j=0;j<mod_right.options.length;j++){
mod_right.options[j].selected=" selected";
}
}
</script>
<script language="javascript">
var style_key;
function change_mystyle(my){
style_key=my.options[my.selectedIndex].value;
if(style_key == '114la'){
document.getElementById('shoostyleicon').src='$Murl/images/114la/115.gif';
}
}
</script>
<script language="javascript">
function setindex_left_right(){
var mod_left =document.getElementById("index_left");
var mod_right =document.getElementById("index_right");
for( var i=0;i<mod_left.options.length;i++){
mod_left.options[i].selected=" selected";
}
for( var j=0;j<mod_right.options.length;j++){
mod_right.options[j].selected=" selected";
}
}
</script>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询