2013-06-08 2 views
0

사진 갤러리를 만들려고합니다. 하나의 엄지 사진을 클릭하면 쇼케이스에 표시되어야합니다. 하지만 어떻게 든 함수 chng1는 호출하지 못할asp에서 javascript 함수 호출

<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

JS 기능은 당신이

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

} 

<image>, 그것은 <img>

유효하지 않은 HTML 태그입니다 자바 스크립트 함수 호출에 괄호를 생략 할 수는 같아야합니다
<img id = <%=id%> onClick = "chng1('showcase', '<%=id%>')" src = <%=src1%> style = "position:absolute; width:100px; height:100px;"> 
+0

고맙습니다 .-- 그것이 작동합니다. –