在asp中调用javascript函数

时间:2013-06-08 10:45:19

标签: javascript function asp-classic call

我正在尝试制作照片库,点击一张拇指照片时,必须在展示中展示。但不知何故,函数chng1不能被调用,

<script language="javascript">
function chng1(image1,image2)
{
    alert "im here";
    document.getElementById(image1).src = document.getElementById(image2).src;

}
===============================================
   <div class = "photogrid">

   <table>
   <%
    dim i, j, src1,id
    i = 1
    j = 2
    do while i < 14
        src1 = "jor"
        id = "jor"
        src1 = src1 & i & ".jpg"
        id = id & i
    %>
        <tr style = "height:140px;width:250px;"> 
            <td style = "width:100px;">
                <image id = <%=id%>  onClick = "chng1('showcase', '<%=id%>')" src = <%=src1%> style = "position:absolute; width:100px; height:100px;">
            </td>
            <td style = "width:100px;">
                <image src = <%=src1%> style = "position:absolute; width:100px; height:100px;"></image> 
            </td>
            <td style = "width:100px;">
                <image src = <%=src1%> style = "position:absolute; width:100px; height:100px;"></image> 
            </td>
        </tr>
    <%
    i = i + 1
    loop
   %>
   </table>
   </div>

1 个答案:

答案 0 :(得分:1)

Js函数看起来应该是,你不能在JavaScript函数调用中省略括号

function chng1(image1,image2)
{
    alert ("im here");
    document.getElementById(image1).src = document.getElementById(image2).src;

}

<image>不是有效的html标记,而是<img>

<img id = <%=id%>  onClick = "chng1('showcase', '<%=id%>')" src = <%=src1%> style = "position:absolute; width:100px; height:100px;">