(php) 如何放置按钮以获取新的输入字段(内图) [英] (php) How can put button to get new inputing field (picture inside)

查看:28
本文介绍了(php) 如何放置按钮以获取新的输入字段(内图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 PHP 编码新手,所以我有两个问题要问...

如果我想通过单击+"按钮(如下图)获得更多输入字段该怎么办

点击+"按钮后会出现下图的输入框

所以...第一个问题,我该怎么做?

第二个问题,在我可以这样做之后,我怎样才能将这些数据存储在同一个表中.

例如,Education 表包含 ID(自动编号)、用户 ID、学位、专业、大学、年份和荣誉.

当一个用户像这样输入他们的数据时

假设User ID是10000,那么表中应该是这样存储的...

(1)ID(Autonumberred),(2)User ID,(3)Degree,(4)Major,(5)University,(6)Year 和(7)Honour.

(1)00001, (2)10000, (3)硕士学位, (4)信息技术, (5)易三仓大学, (6)2014, (7)无.

(1)00002,(2)10000,(3) 学士学位,(4) 商业数据分析,(5) 国政大学,(6)2012,(7) 优等生.

提前致谢.

解决方案

$(document).ready(function() {$("#more").click(function() {$("#clone" ).clone().appendTo("#main_wrap");});});

input{ width:200px;浮动:左;}选择{宽度:200px;浮动:左;}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><form action="submit.php" method="post"><div style="width:250px;"id="main_wrap"><div id="clone" style="float:left; width:100%;"><选择名称="教育[]"><option value="" selected="selected">教育</option><option value="1">value 1</option><option value="2">value 2</option><option value="3">value 3</option></选择><input type="text" name="in[]" placeholder='In'><input type="text" name="from[]" placeholder='From'><选择名称=年份[]"><option value="" selected="selected">年份<option value="2013">2013</option><option value="2014">2014</option><option value="2015">2015</option></选择></br>

<div style="float:left;"><input type="button" value="more" id="more" style="float:left;">

<div style="float:left;"><input type="submit" value="Submit Form" style="float:left;">

并在您的 submit.php 文件中使用 $_POST 获取所有值并插入 db

";打印_r($_POST);}?>

I'm new to PHP coding so I have two questions to ask in the case that...

What if I want to get more input field by clicking the "+" button like the picture below

After click "+" button it will provide the input box like the picture below

So... first question, how can I do like this?

And second question, after I can do like this how can I get these data to store in the same table.

For Example, Education table has ID(Autonumberred), User ID, Degree, Major, University, Year and Honour.

When one user input their data like this

Suppose the User ID is 10000, then in the table should store like this...

(1)ID(Autonumberred), (2)User ID, (3)Degree, (4)Major, (5)University, (6)Year and (7)Honour.

(1)00001, (2)10000, (3)Master Degree, (4)Information Technology, (5)Assumption University, (6)2014, (7)None.

(1)00002, (2)10000, (3)Bachelor Degree, (4)Business Data Analysis, (5)Thammasat University, (6)2012, (7)Magna Cum Laude.

Thank you in advance.

解决方案

$(document).ready(function() {
	$("#more").click(function() {
		$("#clone" ).clone().appendTo("#main_wrap");
	});
});	

input{ width:200px; float:left;}select{ width:200px; float:left;}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form action="submit.php" method="post">
<div style="width:250px;" id="main_wrap">
	<div id="clone" style="float:left; width:100%;">
		<select name="education[]">
			<option value="" selected="selected">Education</option>
			<option value="1">value 1</option>
			<option value="2">value 2</option>
			<option value="3">value 3</option>
		</select>
		<input type="text" name="in[]" placeholder='In'>
		<input type="text" name="from[]" placeholder='From'>
		 <select name="year[]">
				<option value="" selected="selected"> Year</option>
				<option value="2013">2013</option>
				<option value="2014">2014</option>
				<option value="2015">2015</option>
		 </select>
		 </br>
	</div>
</div>
<div style="float:left;">
	<input type="button" value="more" id="more" style="float:left;">
</div>
<div style="float:left;">
	<input type="submit" value="Submit Form" style="float:left;">
</div>
</form>

And in your submit.php file use $_POST to get all the values and insert into db

<?php 
if(isset($_POST))
{
    echo "<pre>";
    print_r($_POST);
}   
?>

这篇关于(php) 如何放置按钮以获取新的输入字段(内图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
PHP最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆