你对我的问题有任何建议吗?我需要同时使用get和post.得到因为我需要输出用户键入的内容.并发布因为我需要访问与该输入相关的mysql数据库.它看起来像这样:
<form name="x" method="get" action="x.php">
<input name="year" type="text">
<select name="general" id="general">
<font size="3">
<option value="YEAR">Year</option>
</form>
Run Code Online (Sandbox Code Playgroud)
这将输出mysql的内容,具体取决于用户将检查的内容:
<form name="y" method="post" action"y.php">
<input name="fname" type="checkbox">
</form>
Run Code Online (Sandbox Code Playgroud)
这两个组合的形式动作看起来像这样:
<?php
if($_POST['general'] == 'YEAR'){
?>
<?php echo $_GET["year"]; ?>
<?php
$result2 = mysql_query("SELECT * FROM student
WHERE student.YEAR='$syear'");
?>
<table border='1'>
<tr>
<?php if ( $ShowLastName ) { ?><th>LASTNAME</th><?php } ?>
<?php if ( $ShowFirstName ) { ?><th>FIRSTNAME</th><?php } ?>
</tr>
<?php while ( $row = mysql_fetch_array($result2) ) {
if (!$result2) {
}
?> …Run Code Online (Sandbox Code Playgroud) 我要求将所有字段从一个表单复制到另一个表单.因此,我不是逐字段地复制,而是使用jQuery编写了一个例程form2form.
function form2form(aF1, aF2) {
var selection = "#" + aF1 + " .copy";
$(selection).each(function() {
document.forms[aF2].elements[$(this).attr('name')].value = $(this).val();
});
}
Run Code Online (Sandbox Code Playgroud)
日常工作.例程要求在输入表单字段中有一类副本,否则我不知道如何获取表单中的所有字段.("#form:input")跳过单选按钮并选择字段.
所以我的问题是.
是否有内置功能,所以我不需要这个?有没有更好的方法来编写选择?如何修改例程而不需要该类.我可以传递表单对象而不是表单名称作为文本吗?一般来说有更好的方法吗?
这是一个有效的完整页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test form2form in jQuery</title>
<script type="text/javascript" src="../scripts/jquery.js"></script></head>
<script type="text/javascript">
function form2form(aF1, aF2) {
var selection = "#" + aF1 + " .copy";
$(selection).each(function() {
document.forms[aF2].elements[$(this).attr('name')].value = $(this).val();
});
}
function testform2form () {
form2form ('form1', 'form2' );
}
</script> …Run Code Online (Sandbox Code Playgroud)