我正在尝试在主题选项页面中创建动态行,并尝试将这些数据保存在序列化数据中。
随着我添加工作经验,新行被添加..现在我只想将这些值保存在序列化数据中并相应地进行排序(可能是开始日期或序列号)。
MY JQUERY CODE
jQuery('a.add-author').click(function(event) {
alert("asdas");
event.preventDefault();
counter++;
var newRow = jQuery('<tr><td><input style="width:200px" type="text" name="designation' + counter + '"/></td>
<td><input style="width:200px" type="text" id="start_date' + counter +'" name="start_date' + counter + '"/></td>
<td><input style="width:200px" id="end_date' + counter +'" type="text" name="end_date' + counter + '"/></td></tr>');
jQuery('table.authors-list').append(newRow);
$("#start_date"+ counter).datepicker();
$("#end_date"+ counter).datepicker();
});
我的OPTIONS ARRAY
array(
"name" => "Designation",
"desc" => "Enter your Designation of company.",
"id" => $shortname."_designation",
"type" => "workexp",
"std" => ""
)
我的HTML代码类型workexp
case 'workexp':
?>
<a href="#" title="wrk_exp" class="add-author">Add Work Experience</a>
<table class="authors-list" border="1" bordercolor="#ddd"
style="background-color:#F5F5F5" width="100%" cellpadding="3" cellspacing="3">
<tr><td>Designation</td><td>StartDate</td><td>EndDate</td></tr>
<tr>
<td><input style="width:200px" type="text" name="designation"/></td>
<td><input style="width:200px" type="text" id="start_date" name="start_date"/></td>
<td><input style="width:200px" type="text" id="end_date" name="end_date"/></td>
</tr>
</table>
<?php
break;
保存按钮后的我的代码
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
foreach ($options as $value) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] );
}
foreach ($options as $value) {
if( isset( $_REQUEST[ $value['id'] ] ) ) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] );
} else {
delete_option( $value['id'] );
}
}
header("Location: admin.php?page=theme-options.php&saved=true");
die;
}
}