2015-01-20 1 views
0

javascript를 사용하여 제 버튼을 숨길 수 없습니다. 제 코드는 여기 있습니다. (버튼으로 이미지를 사용했습니다)자바 스크립트 : asp.net 버튼 가시성을 false로 설정하십시오.

<img alt="" src="images/search-icon.png" width="16" height="16" style="display: inline;height:16px;cursor:pointer; width: 16px;" onclick="ViewLookUpPayment('<%=btnShowCorpCode.ClientID %>');" /> 

다음은 자바 스크립트 코드입니다. 내가 이미지를 클릭

function ViewLookUpPayment(bShow) 
{ 
var button1 = document.getElementById(bShow); 
    button1.style.visibility = "visible"; 
} 

때마다이 런타임 오류가

enter image description here

이해 할 수없는 이유 런타임 오류가 발생, 사람이 하나 도와 줄 수 팝업?

+0

함수에 이름이 있습니까? – sh1rts

+1

@ sh1rts 예, 누군가 내 질문을 편집했습니다. –

+0

버튼의 ID 모드를 고정으로 설정하십시오. ID를 알려진 값으로 설정하십시오. 자바 스크립트 호출을 하드 코드합니다. 브라우저에서 열고 디버그하십시오. 실제로 요소를 가져올 수 있는지 확인한 다음 문제를 찾을 때까지 푸십시오. – Krisc

답변

0

<img alt="" src="images/search-icon.png" 
width="16" height="16" style="display: 
inline;height:16px;cursor:pointer; width: 16px;" 
onclick="ViewLookUpPayment('<%=btnShowCorpCode.ClientID %>');" /> 


function ViewLookUpPayment(obj) 
{ 

    document.getElementById(obj).style.display = "block"; 
} 
+0

'bShow'는 하드 코딩 된 값이 아닌 매개 변수입니다.이 문제는 해결되지 않습니다. – karthikr

+0

@Ganesh_Devlekar 기본적으로 페이지를로드 할 때 btnShowCorpCode의 가시성이 false로 설정되어 있기 때문에 런타임 오류가 발생해도 stille입니다. 나는 당신의 코드를 시도했다. –

0

당신은 'ID'이미지 태그에 속성을 설정 했 시도?

"document.getElementById(bShow)"일 수 있습니다. 'undefined'을 반환합니다. "var button1"이 무엇인지 확인하십시오 (예 : console.log(button1))

관련 문제