2012-08-28 5 views
0

단추 중 하나가 클릭 될 때 스크립트 중 하나만 실행하면 문제가 있습니다. 이 코드는 버튼을 클릭 할 때 2 개의 스크립트를 함께 실행합니다. 한 번에 하나의 스크립트 만 실행하고 특정 버튼은 특정 스크립트를 실행하는 방법은 무엇입니까? 도와 주셔서 감사합니다. 아래는 제 코드입니다.특정 단추를 클릭 할 때 특정 코드 실행

<html> 
<head> 
<script language="javascript" type="text/javascript"> 
    function popup(){ 
     window.location = 'testing.php?run=shell'; 
    } 
    function popdown(){ 
     window.location = 'testing.php?run=shell'; 
    } 
</script> 
</head> 
<body> 
<input type="button" onclick="popup()" value="popup"> 
<?php 
if(isset($_GET['run']) && ($_GET['run'] == 'shell')){ 
    echo shell_exec('sh bash_test.sh'); 
} 
?> 
<input type="button" onclick="popdown()" value="popdown"> 
<?php 
if(isset($_GET['run']) && ($_GET['run'] == 'shell')){ 
    echo shell_exec('sh bash_run.sh'); 
} 
?> 
</body> 
</html> 
+0

가 동일한 작업을 수행합니까? – Oriol

+0

번호. 다르다 – user1502809

답변

0

이 시도 스크립트를 표시 :

<html> 
<head> 
<script language="javascript" type="text/javascript"> 
    function popup(){ 
     window.location = 'testing.php?run=test'; 
    } 
    function popdown(){ 
     window.location = 'testing.php?run=run'; 
    } 
</script> 
</head> 
<body> 
<input type="button" onclick="popup()" value="popup"> 
<?php 
if(isset($_GET['run']) && ($_GET['run'] == 'test')){ 
    echo shell_exec('sh bash_test.sh'); 
} 
?> 
<input type="button" onclick="popdown()" value="popdown"> 
<?php 
if(isset($_GET['run']) && ($_GET['run'] == 'run')){ 
    echo shell_exec('sh bash_run.sh'); 
} 
?> 
</body> 
</html> 
+0

하! 당신을 때려! –

0

그냥 별도로

<html> 
<head> 
<script language="javascript" type="text/javascript"> 
    function popup(){ 
     window.location = 'testing.php?run=shell1'; 
    } 
    function popdown(){ 
     window.location = 'testing.php?run=shell2'; 
    } 
</script> 
</head> 
<body> 
<input type="button" onclick="popup()" value="popup"> 
<?php 
if(isset($_GET['run']) && ($_GET['run'] == 'shell1')){ 
    echo shell_exec('sh bash_test.sh'); 
} 
?> 
<input type="button" onclick="popdown()" value="popdown"> 
<?php 
if(isset($_GET['run']) && ($_GET['run'] == 'shell2')){ 
    echo shell_exec('sh bash_run.sh'); 
} 
?> 
</body> 
</html> 
관련 문제