Php 表单的CSS问题
这里的初学者。我正在处理一个表单,用户在表单中选择一个选项并单击按钮。在后端,将执行一些操作,结果将是一些文本,这些文本将精确地显示在表单中。这是我的密码:Php 表单的CSS问题,php,css,ajax,Php,Css,Ajax,这里的初学者。我正在处理一个表单,用户在表单中选择一个选项并单击按钮。在后端,将执行一些操作,结果将是一些文本,这些文本将精确地显示在表单中。这是我的密码: <form name="my_form" id="input" style = "background-color: #e1dddd; padding: 10px; border-radius: 5px;" action="actionpage.php" method="post"> <div clas
<form name="my_form" id="input" style = "background-color: #e1dddd; padding: 10px; border-radius: 5px;" action="actionpage.php" method="post">
<div class="row" id="output">
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<label>Title of the form</label><br><br>
<label>Choose a functionality</label><br>
<select name="message">
<option value="functionality 1">Choose One</option>
<option value="functionality 2">Choose One</option>
</select><br>
<button type="initiate" name="" id="" value="Initiate" class="btn btn-primary btn-lg">Initiate</button>
</div>
</div>
</div>
</div>
</form>
<script type="text/javascript"> //this is to stop the form to go to another page
$(document).ready(function () {
$('#my_form').on('submit', function(e) {
e.preventDefault();
$.ajax({
url : $(this).attr('action') || window.location.pathname,
type: "GET",
data: $(this).serialize(),
success: function (data) {
$("#output").html(data);
},
error: function (jXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
});
});
</script>
actionpage.php包含以下代码:
<?php
//some action happening here.
?>
<form name="my_form2" id="" style = "background-color: #e1dddd; padding: 10px; border-radius: 5px;" action="" method="post">
<div class="row">
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<label>Text will appear here.</label><br>
<label>Text will appear here.</label><br>
<label>Text will appear here.</label><br>
</div>
</div>
</div>
</div>
</form>
现在的问题是,执行操作后出现在表单中的文本在表单中的位置不正确。一些文本从表单的左侧移出
非常感谢您的建议、代码示例和指导。您的ajax为表单引用了错误的id
<!-- notice your id is input. In your ajax it is using my_form -->
<form name="my_form" id="input"
其次,ajax将文本放入输出id中,但没有HTML具有您发布的id
这是一个带有工作示例的示例。希望它能解决您面临的奇怪宽度问题。除了内联样式之外,您还有CSS吗?请同时发布样式。@ZombieCode我还没有任何CSS,但我不确定我可以使用什么CSS来强制文件文本位于彩色表单中。您可以通过检查元素来检查它。@Rohil_PHPBeginner,我自己制作了这个表单,所以我没有添加样式,但我不知道文本为什么不位于表单中!是本地的还是现场的?如果直播,你能给我们一个链接吗?