用于可编辑数据的编辑器

时间:2018-10-22 20:06:17

标签: javascript php html

我正在尝试让我的用户能够返回并编辑他们输入的日期。我的页面返回用户创建的事件的列表。我有一个包含标题,开始日期和结束日期的表格。我想在删除按钮旁边添加一个按钮,用户可以按下该按钮,以便将他们带回到显示以前保存的数据的表单,并允许他们编辑和保留此表单。任何帮助将不胜感激。我当前的代码如下:

 <?php

if(!$user->isLoggedIn()) {
    Redirect::to('/index.php');
} 
//require_once '../core/init.php';
$user = new User();

$user->bring_li('date', array(
        'id'    =>  array(
            'operator'  => '!=',
            'value'     => '')
                ), 'd_order_o', 'cmp_r');

    $output ="";
//'.date('l, F jS, Y', strtotime($row->start)).'
    foreach ($user->variable_pro() as $row) {
         if($user->data()->access == 2) { 
        $output .= '<tr class="account_row" id="c_'.$row->id.'">
<td >

</td>
<td >

<span class="balance-btc ">
<span class="full">'.date('M d, y', strtotime($row->start)).' - '.date('M d, y', strtotime($row->end)).'</span>
</span></td>
<td >
<span >
<span class="full">'.$row->event.'</span>
</span>


</td>


<td class="settings">
<li><a href="#" onclick="Delete(\''.$row->id.'\')" >Delete</a></li>
<li><a href="#" onclick="switchTab(\''.$row->id.'\')">Edit</a></li>

</td>
</tr>';
         } else {
             $output .= '<tr class="account_row" id="c_'.$row->id.'">
<td class="clickable type">

</td>
<td class="clickable name">

<span class="balance-btc ">
<span class="full">'.date('M d, y', strtotime($row->start)).' - '.date('M d, y', strtotime($row->end)).'</span>
</span></td>
<td class="clickable balance">
<span class="balance-btc ">
<span class="full">'.$row->event.'</span>
</span>


</td>

<td class="settings"></td>
</tr>';
         }
    };


if(isset($_POST['date'])) {
            try {
                $user->create('date', array(
                    'event'     =>trim(Input::get('title')),
                    'start'     =>date('Y-m-d',strtotime(Input::get('start_date'))),
                    'end'   =>date('Y-m-d',strtotime(Input::get('end_date'))),
                    'add_by'    =>$username,
                ));


                    $user->bring_li('users', array(
                        'id'    =>  array(
                            'operator'  => '!=',
                            'value'     => ''),
                        'access'    =>  array(
                                'operator'  => '=',
                                'value'     => '2')
                                ), 'results');

        if($user->varcount()>0) {
            foreach ($user->variable_pro() as $row) {

    $subject = "Reslife Notification - New Important Date Added";
    $message = "Hello ".$row->name.",\n\nA new important date has been added by admin ".$display." titled ".Input::get('title')." for dates starting on ".date('l, F jS, Y', strtotime(trim(Input::get('s_month')).'/'.trim(Input::get('s_day')).'/'.trim(Input::get('s_year'))))." and ending on ".date('l, F jS, Y', strtotime(trim(Input::get('e_month')).'/'.trim(Input::get('e_day')).'/'.trim(Input::get('e_year'))))."

    Thank you,
    Reslife Connect Notification";
    $email = "no-reply@reslifeconnect.org";
    $from = "".$email."";
    $headers = "From:" . $from;
        mail($row->email, $subject, $message, $headers);

                }
        }
        } catch(Exception $e) {
                die($e->getMessage());
        }

    }


$ad6 = '<li class="tabItem tabAdd" onclick="switchTab(\'.tabAdd\', \'#add\', \'add\')"><a class="tabActive">Add Dates</a></li>';

$ad7 = '<div id="add" class="add-date">
<form method="post">
<div class="control-group">
<label class="control-label">Title</label>
<div class="controls">


<input name="title" placeholder="Title" class="street-address" type="text"></div>
</div>
<div class="control-group">
<label class="control-label">Start Date</label>
<div class="controls">

<input name="start_date" placeholder="format: Jan 01, 1970" class="dates" type="text" id="start_date"></div>
</div>
<div class="control-group ">
<label class="control-label" for="identity_verification_dob_day">End Date</label>
<div class="controls">

<input name="end_date" placeholder="format: Jan 01, 1970" class="dates" type="text" id="end_date"></div>
</div>
<div class="control-group">
<div class="controls">
<input type="submit" name="date" value="Save" class="btn btn-primary">
</div>
</div></form>
</div>';

和我的切换标签功能如下:

function switchTab(tab, tabPage, tabLink, autoSwt) {
    window.location.hash = tab;
    var pageList= ['.tabBrowse', '#browse', '.tabPast', '#past', '.tabCreate', '#create', '.tabMyevents', '#myevents', '.tabView', '#view', '.tabEval', '#eval'];
    var count = 0;
    var stepCount = 1;
    $(tab+" > .tabActive").addClass("showd");
    $(tabPage).addClass("show");
    while(count < 12) {
        if(pageList[count] != tab) {
            $(pageList[count] + "> .tabActive").removeClass("showd");
            $(pageList[stepCount]).removeClass("show");
        }
        count = count+2;
        stepCount = stepCount+2;
    }

}

当用户单击编辑按钮时,如何允许显示添加日期页面。我希望单击编辑按钮并在用户进行任何更改时更新这些字段中已经存储的内容。

0 个答案:

没有答案