请更正此Java脚本错误 [英] Please correct this java script error

查看:87
本文介绍了请更正此Java脚本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
请检查下面的代码,并告诉我如何将textbox的值转换为javascript函数.


Hello Guys
Please check this below code and tell me how can I get the value of textbox into javascript function .


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
function setElementVisibility(elementToSet, showItSwitch, keepPlacementSwitch){
 if (showItSwitch) {
   elementToSet.style.display = "inline";
   elementToSet.style.visibility = "visible";
 }
 else{
     elementToSet.style.display = "inline";
     elementToSet.style.visibility = "hidden";
   }
   
 


function hideTable(){
 setElementVisibility(document.getElementById("a"), false, document.getElementById(''TextBox1'').value);
}

function removeTable(){
 setElementVisibility(document.getElementById("a"), false, call(a));
}

function showTable(){
 setElementVisibility(document.getElementById("a"), true);
}
</script>

<style type="text/css">
<!--
#Layer1 {
    position:absolute;
    width:50px;
    height:39px;
    z-index:1;
    left: 273px;
    top: 177px;
}
#Layer2 {
    position:absolute;
    width:43px;
    height:40px;
    z-index:1;
    left: 0px;
    top: 0px;
}
-->
</style>
</head>
<body>
<div>
    <form id="form1" runat="server">
    <div>
    <div id="Layer1"><img src="green.gif" width="28" height="28" alt="a" />
  <div id="Layer2"><img src="red.gif" width="28" height="28" alt="a" id="a"/></div>
</div>
<p>&nbsp;</p>
  Insert  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </form>
<p>&nbsp;</p>
<p><img alt="a" src="map.gif" width="672" height="587" usemap="#Map" />
  <map id="Map">
    <area  alt="a" shape="poly" onclick="hideTable()" 
coords="267,102,253,96,239,80,239,62,251,
48,241,34,229,24,236,21,243,17,252,10,267,9,
281,13,287,25,294,30,309,45,324,44,340,35,355,
42,351,56,345,74,332,85,349,101,333,107,312,
105,306,97,295,93,286,90,279,97,268,105,266,
104" href="#" />
              <area alt="a" shape="poly" id="Area1" style="border-color: #000000" 
coords="221,275,204,253,168,238,
155,210,166,194,202,187,226,168,238,
155,268,189,270,209,245,232,282,
220" href="#" />
  </map>
 
</p>

    </div>
</body>
</html>


推荐答案

您好!
该功能没有右括号:
function setElementVisibility(elementToSet, showItSwitch, keepPlacementSwitch){

这是正确的方法:
Hello!
This function has not closing bracket:
function setElementVisibility(elementToSet, showItSwitch, keepPlacementSwitch){

Here''s the right way:
function setElementVisibility(elementToSet, showItSwitch, keepPlacementSwitch){<br />
 if (showItSwitch) {<br />
   elementToSet.style.display = "inline";<br />
   elementToSet.style.visibility = "visible";<br />
 } else {<br />
     elementToSet.style.display = "inline";<br />
     elementToSet.style.visibility = "hidden";<br />
  }<br />
}



请注意最后一个括号.
要获得折页盒的价值,您必须将其ID注入javascript代码:方法如下:
setElementVisibility(document.getElementById("a"), false, document.getElementById(''<%= TextBox1.ClientID %>'').value);

问候



Please pay attention to the last bracket.
To get the value of the cleck-box, you will have to inject its ID to javascript code: here''s how:
setElementVisibility(document.getElementById("a"), false, document.getElementById(''<%= TextBox1.ClientID %>'').value);

Regards


我认为这会很好

This will do good i think

function setElementVisibility(elementToSet, showItSwitch, keepPlacementSwitch)
{
     if (showItSwitch) 
     {
       elementToSet.style.display = "inline";
       elementToSet.style.visibility = "visible";
     }
 else
    {
       elementToSet.style.display = "inline";
       elementToSet.style.visibility = "hidden";
     }
}


这篇关于请更正此Java脚本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆