2012-08-28 68 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> 
相關問題