作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嘿,谁能帮我把它做成一个对象。
显然,我的代码并非全部都在这里,但我相信您会明白要点。
<?php
$product_name_1 = $_POST['product_name_1'];
$region_1 = $_POST['region_1'];
$start_date_1 = $_POST['start_date_1'];
$end_date_1 = $_POST['end_date_1'];
$sku_1 = $_POST['sku_1'];
$product_name_2 = $_POST['product_name_2'];
$region_2 = $_POST['region_2'];
$start_date_2 = $_POST['start_date_2'];
$end_date_2 = $_POST['end_date_2'];
$sku_2 = $_POST['sku_2'];
$product_name_3 = $_POST['product_name_3'];
$region_3 = $_POST['region_3'];
$start_date_3 = $_POST['start_date_3'];
$end_date_3 = $_POST['end_date_3'];
$sku_3 = $_POST['sku_3'];
?>
<form action="" method="post" accept-charset="utf-8">
<div id="product_information">
<table id="product_1">
<tr>
<th><label for="product_name">Product Name</label></th>
<th><label for="region">Select A Region</label></th>
<th class="date"><label for="start_date">Start Date</label></th>
<th class="date"><label for="end_date">End Date</label></th>
<th><label for="sku">SKU</label></th>
</tr>
<tr>
<td><input type="text" name="product_name_1" value="" id="product_name_1"></td>
<td><input type="radio" name="region_1" value="upper_north" id="upper_north_1"><label for="upper_north_">Upper North Island</label><br />
<input type="radio" name="region_1" value="lower_north" id="lower_north_1"><label for="lower_north_">Lower North Island</label><br />
<input type="radio" name="region_1" value="south_island" id="south_island_1"><label for="south_island">South Island</label> </td>
<td class="date"><input type="text" class="date" name="start_date_1" value="" id="start_date_1"></td>
<td class="date"><input type="text" class="date" name="end_date_1" value="" id="end_date_1"></td>
<td><input type="text" name="sku_1" value="" id="sku_1"></td>
</tr>
</table>
<span class="product"></span>
<div class="add-product"> </div>
</div>
<script type="text/javascript" charset="utf-8">
var i = 1;
$('.add-product').click(function(){
i++;
$('span.product').replaceWith('<table id="product_'+i+'">'
+'<tr>'
+'<th><label for="product_name">Product Name</label></th>'
+'<th><label for="region">Select A Region</label></th>'
+'<th class="date"><label for="start_date">Start Date</label></th>'
+'<th class="date"><label for="end_date">End Date</label></th>'
+'<th><label for="sku">SKU</label></th>'
+'</tr>'
+'<tr>'
+'<td><input type="text" name="product_name'+i+'" value="" id="product_name'+i+'"></td>'
+'<td><input type="radio" name="region'+i+'" value="upper_north" id="upper_north'+i+'"><label for="upper_north'+i+'">Upper North Island</label><br />'
+'<input type="radio" name="region'+i+'" value="lower_north" id="lower_north'+i+'"><label for="lower_north'+i+'">Lower North Island</label><br />'
+'<input type="radio" name="region'+i+'" value="south_island" id="south_island"><label for="south_island">South Island</label> </td>'
+'<td class="date"><input type="text" class="date" name="start_date'+i+'" value="" id="start_date'+i+'"></td>'
+'<td class="date"><input type="text" class="date" name="end_date'+i+'" value="" id="end_date'+i+'"></td>'
+'<td><input type="text" name="sku'+i+'" value="" id="sku'+i+'"></td>'
+'</tr>'
+'</table>'
+''
+'<span class="product"></span>');
});
</script>
最佳答案
您可以使用此对象开始。之后定义保存和检索它的方法。也许还有适当的构造函数,用于从 post 参数创建不同的产品。
class Product {
private $Name;
private $Region;
private $StartDate;
private $EndDate;
private $Sku;
public function setName( $value )
{
//make some validation or manipulation on data here, if needed
$this->Name = $value;
}
public function getName()
{
return $this->Name;
}
public function setRegion( $value )
{
//make some validation or manipulation on data here, if needed
$this->Region = $value;
}
public function getRegion()
{
return $this->Region;
}
public function setStartDate( $value )
{
//make some validation or manipulation on data here, if needed
$this->StartDate = $value;
}
public function getStartDate()
{
return $this->StartDate;
}
public function setEndDate( $value )
{
//make some validation or manipulation on data here, if needed
$this->EndDate = $value;
}
public function getEndDate()
{
return $this->EndDate;
}
public function setSku( $value )
{
//make some validation or manipulation on data here, if needed
$this->Sku= $value;
}
public function getSku()
{
return $this->Sku;
}
}
希望对您有所帮助!
关于php - 谁能帮我把它做成一个对象。 (php),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2293234/
我是一名优秀的程序员,十分优秀!