나는 하나 이상의 함수를 onchange에 두는 방법을 찾고 있었고 다음과 같은 것을 발견했습니다 : onchange = "function1(); function2();"
. 내 문제는 여기에 나와있는 예제를 따라했지만 function1 만 작동하고 function2는 작동하지 않습니다. 그렇지 않으면 onchange = "function2(); function1();"
으로 바꾸면 function2 만 작동하고 function1은 작동하지 않습니다.두 개의 함수를 하나의 함수로 호출 onchange = not working
아이디어가 있으십니까? 감사합니다. .
기능, 나는 아약스 사용 :
function1(test)
{
var kode = test.value;
if (!kode) return;
xmlhttp.open('get', '../template/get_name-opr.php?kode='+kode, true);
xmlhttp.onreadystatechange = function() {
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200))
{
//alert(kode);
document.getElementById("code").innerHTML = xmlhttp.responseText;
}
return false;
}
xmlhttp.send(null);
}
function2(test)
{
var kode = test.value;
if (!kode) return;
xmlhttp**1**.open('get', '../template/get_name2-opr.php?kode='+kode, true);
xmlhttp**1**.onreadystatechange = function() {
if ((xmlhttp**1**.readyState == 4) && (xmlhttp**1**.status == 200))
{
//alert(kode);
document.getElementById("code2").innerHTML = xmlhttp**1**.responseText;
}
return false;
}
xmlhttp**1**.send(null);
}
내 문제를 해결하기 위해, 나는 두 XMLHTTP 다른 만들었습니다. (xmlhttp 및 xmlhttp1).
함수에 JavaScript 오류가 있습니까? –
@ShashankKadne Hummm .. 내가 오류를 호출하는 경우, 나는 방화범이 끌려서 function1에 대한 (함수의 결과) "http : //localhost/template/get_name-opr.php? kode = f 중단됨 (빨간색 모든 글꼴, 응답 없음, 결과 없음), function2 "http : //localhost/template/get_name-opr.php? kode = f"(이것은 응답을 얻는 하나의 응답입니다. 결과). 그게 전부 야! 나는 혼란 스럽다 (=, =) "a. – candies
오류 콘솔에 오류가 있는지 확인하십시오 (도구> 오류 콘솔) –