Javascript 如何从PHP中的jquery mobile开/关滑块中提取值
我从w3schools中找到了jquerymobile on和off滑块输入的代码。但我不知道如何从输入中取出值并用PHP显示。以下是W3S上的HTML:-Javascript 如何从PHP中的jquery mobile开/关滑块中提取值,javascript,php,jquery,html,jquery-mobile,Javascript,Php,Jquery,Html,Jquery Mobile,我从w3schools中找到了jquerymobile on和off滑块输入的代码。但我不知道如何从输入中取出值并用PHP显示。以下是W3S上的HTML:- <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jque
<!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中从这个输入中获取值。提前感谢我看到您的表单操作是demoform.asp。是这样吗?PHP页面将附带.PHP扩展名。我只使用.PHP扩展名。您需要JS来检索值。由于我对JS
$(“#switch”).val()了解不多,您能告诉我代码吗代码>是翻转开关的值。
if(isset($_POST['switch']))
{
echo "On. The user On the switch.";
}
else
{
echo "Off. The user kept the switch Off.";
}