2015-08-28 66 views
2

我正在尝试创建一个按钮,点击它时,它会显示一个带有简报注册表单的小框。显示/隐藏表格无法正常工作

我写过我的JavaScript,但似乎没有工作。

我会很感激你可以告诉我为什么这不起作用的任何指针。

<script> 
    function setVisibility('subscribe_form') { 
    if (document.getElementById('bt1').value == 'Hide Layer') { 
     document.getElementById('bt1').value = 'Show Layer'; 
     document.getElementById('subscribe_form').style.display = 'none'; 
    } else { 
     document.getElementById('bt1').value = 'Hide Layer'; 
     document.getElementById('subscribe_form').style.display = 'block'; 
    } 
    } 
</script> 

<input type='button' name='type' id='bt1' value='Show Layer' onclick="setVisibility('subscribe_form');";>   
<form action="%%GLOBAL_ShopPath%%/subscribe.php" method="post" id="subscribe_form" class="subscribe_form" name="subscribe_form"> 
+0

删除引号' '''函数setVisibility(subscribe_form){' –

+0

'函数setVisibility(' subscribe_form')' - 你的参数被错误地delcared。尝试删除所有“subscribe_form”标签的引号 – Tro

+0