为了有用,您的输入标签需要名称属性。
使用部门和 CSS,如下所示:
<style>
.part1 {float: left}
.part2 {float: right}
</style>
<form action="actions.php">
<div class="part1">
<input name="input1" type="text">
<input name="input2" type="text">
<input type="submit" name="button" id="button" value="submit" />
</div>
<div class="part2">
<input name="input3" type="text">
<input name="input4" type="text">
</div>
</form>
CSS 可用于定位表单的每个部分。
另一种选择是使用 javascript,如下所示:
<form name="form1" action="actions.php">
<input name="input1" type="text">
<input name="input2" type="text">
<input name="input3" type="hidden">
<input name="input4" type="hidden">
<input type="submit" name="button" id="button" value="submit" />
<form name="form2">
<input onBlur="document.form1.input3.value = this.value" name="input3" type="text">
<input onBlur="document.form1.input4.value = this.value" name="input4" type="text">
</form>
反过来也可以:
<form onSubmit="this.input3.value = document.form2.input3.value; this.input4.value = document.form2.input4.value;" name="form1" action="actions.php">
<input name="input1" type="text">
<input name="input2" type="text">
<input name="input3" type="hidden">
<input name="input4" type="hidden">
<input type="submit" name="button" id="button" value="submit" />
<form name="form2">
<input name="input3" type="text">
<input name="input4" type="text">
</form>