87,901
社区成员
发帖
与我相关
我的任务
分享
<input type="radio" name="submitType" value="get"/>
<input type="radio" name="submitType" value="post"/>
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="http://www.my.com/js/jquery.min.js"></script>
</head>
<form action="index.php" methode="get" id="myform">
<input type="radio" name="method" value="post" />post
<input type="radio" name="method" value="get" />get
<input type="submit" value="提交" />
</form>
<script type="text/javascript">
$('input[name=method]').click(function (){
if($(this).val() == 'post'){
$('#myform').attr('method','post');
}else{
$('#myform').attr('method','get');
}
});
</script>
</html>
<?php
if(empty($_GET) && empty($_POST)){
die;
}else if(empty($_POST) && !empty($_GET)){
echo '我是get方式';
print_r($_GET);
}else{
echo '我是post方式';
print_r($_POST);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
$("form").submit(function(){
if($("input").is(":checked")){
var m=$(this).val();
$("form").prop("method",""+m+"");
}
});
});
</script>
</head>
<body>
<form action="">
<input type="radio" name="submitType" value="get"/>get
<input type="radio" name="submitType" value="post"/>post<br/>
<input type="submit"/>
</form>
</body>
</html>