我有一个简单的模态形式:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content modal-lg">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Address Maintenance</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" id="maintainAddress" method='GET' action="test.php">
<div class="form-group">
<label for="addressID" class="col-sm-2 control-label input-sm">Address ID</label>
<div class="col-sm-4">
<input type="text" class="form-control input-sm" id="addressID" placeholder="Address ID">
</div>
<label for="houseNo" class="col-sm-2 control-label input-sm">House No</label>
<div class="col-sm-4">
<input type="text" class="form-control input-sm" id="houseNo" placeholder="House No">
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default">SAVE</button>
<button type="button" class="btn btn-default" data-dismiss="modal">CANCEL</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
test.php是:
<?
$addressID=$_GET["addressID"];
$houseNo=$_GET["houseNo"];
echo $addressID . " " . $houseNo;
?>
在点击“保存”按钮时会调用test.php,但test.php无法接收addressID和houseNo的任何字段值。错误消息是“
注意:未定义的索引:第3行的D:\ proto \ xampp \ htdocs \ scorecard \ test.php中的addressID 注意:未定义的索引:第4行的D:\ proto \ xampp \ htdocs \ scorecard \ test.php中的houseNo
我已尝试将GET更改为POST,但仍无效。
答案 0 :(得分:1)
表单元素应该具有name-attribute set。所以这:
<input type="text" class="form-control input-sm" id="houseNo" placeholder="House No">
应改为:
<input type="text" class="form-control input-sm" id="houseNo" name = "houseNo" placeholder="House No">