2014-04-02 78 views
0

我發現了一個來自w3schools的代碼,用於jquery mobile開啓和關閉滑塊輸入。但我不知道如何從輸入中取出值並通過PHP顯示。這是在w3schools上的HTML: -我如何從jquery mobile開啓和關閉滑塊輸入值

<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css"> 
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> 
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script> 
</head> 
<body> 

<div data-role="page"> 
    <div data-role="main" class="ui-content"> 
    <form method="post" action="demoform.asp"> 
     <label for="switch">Flip Toggle Switch:</label> 
     <input type="checkbox" data-role="flipswitch" name="switch" id="switch"> 
     <br> 
     <input type="submit" data-inline="true" value="Submit"> 
    </form> 
    </div> 
</div> 

</body> 
</html> 

請告訴我如何從PHP中輸入這個值。在此先感謝

+0

您需要JS來檢索值。 – Omar

+0

你能告訴我編碼,因爲我不太瞭解js – user3296690

+0

'$(「#switch」)。val();'是flipswitch的值。 – Omar

回答

0
if(isset($_POST['switch'])) 
{ 
    echo "On. The user On the switch."; 
} 
else 
{ 
    echo "Off. The user kept the switch Off."; 
} 
+0

仍然無法正常工作 – user3296690

+0

我看到您的表單操作是demoform.asp。是對的嗎? PHP頁面將帶有.php擴展名。 –

+0

我只使用.php擴展名 – user3296690