好的,所以现在这种方法非常好用,但是我认为它可能会更加优化,因为有很多重复的代码.
有人想去吗?
var myObj = {
gender:'',
age:'',
children:'',
income:'',
stage2select:'',
day:'',
spend:'',
categories:'',
product:'',
price:'',
quantity:'',
total:''
};
$("#gender li").click(function() {
myObj.gender = $(this).text();
$('#age').show();
update();
});
$("#age li").click(function() {
myObj.age = $(this).text();
$('#children').show();
update();
});
$("#children li").click(function() {
myObj.children = $(this).text();
$('#income').show();
update();
});
$("#income li").click(function() {
myObj.income = $(this).text();
$('#stage2select').show();
update();
});
$("#stage2select :radio").change(function () {
myObj.stage2select = $(this).val();
if ( $(this).val() == 'shopping_patterns') {
$('#day').show();
$('#block3').hide();
$('#block2').show();
}
if ( $(this).val() == 'specific_products') {
$('#product').show();
$('#block2').hide(); …Run Code Online (Sandbox Code Playgroud) 嘿,有人可以帮我把它作为一个对象.
显然不是我的所有代码都在这里,但我相信你会得到这个要点.
<?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" …Run Code Online (Sandbox Code Playgroud)