当前位置: 代码迷 >> JavaScript >> button disabled的有关问题
  详细解决方案

button disabled的有关问题

热度:622   发布时间:2014-01-03 14:10:51.0
button disabled的问题
各位路过的朋友麻烦帮我看看,先谢谢了!
这是jira里边的一个录入数据插件,如图所示,我想设计成这样的效果:当没有点击new按钮的时候,edit和delete按钮是可以操作的,当点击new按钮的时候,edit和delete按钮不能操作且显示成灰色。不过现在点击new按钮的时候,edit和delete按钮都不能显示成灰色,麻烦帮我看看代码,这个应该怎样改?

<h1>success.vm</h1>

$webResourceManager.requireResource("com.shan.PipeLine:PipeLineResource")  

<form method='post' id='Form1'>
<table class="aui">

<div class="search-container">
     <a href="#" class="aui-button" id="newID" onclick="javascript:newone()">new</a>
    </div>
<thead >
<tr >
<th width="120" align="left" heigth="8">
Date
        </th>
<th width="120" align="left" heigth="8">
Plan
        </th>
<th width="120" align="left" heigth="8">
Actual
        </th>
<th width="120" align="left" heigth="8">
Operation
        </th>
    </tr>
</thead>
<tbody >
#foreach($l in $list)
<tr id="data$l.getID()">
<td id="date$l.getID()" >
#set($year=$l.getPipelineDate().getYear()+1900)
#set($minus='-')
#if($month<9)
#set($month="0$month")
#end
#set($yearmonth=" $year$minus$month")
$yearmonth
        </td>
<td id="plan$l.getID()">
$l.getPipelinePlan()
        </td>
<td id="actual$l.getID()">
$l.getPipelineActual()
        </td>
<td >
<a href="#" id="editID" class="aui-button" onclick="javascript:edit($l.getID())"> Edit
            </a>
<a href="#" id="deleteID" class="aui-button" onclick="javascript:deletes($l.getID())"> Delete
            </a>
        </td>
    </tr>
#end

</tbody>
</table>
</form>
<img src="/download/resources/com.shan.PipeLine:PipeLineResource/images/example.png" />


<script type="text/javascript">
function newone() {

    if (window['added'] == 0) {
        var s = inputstring(-1);
        $('tbody').html(s + $('tbody').html());
        window['added'] = 1;
        window['edited'] = 1;
        window['deleted'] = 1;
    }
    
     document.getElementById('newID').disabled = false;
     document.getElementById('editID').disabled = true;
     document.getElementById('deleteID').disabled = true;
    
}
window['added'] = 0;
window['edited'] = 0;
window['deleted'] = 0;


function inputstring(id) {
    var strings;

    if (id == -1) {
        strings = "<div class='search-container'><tr><td style='heigth:8px width:120px'><input id='date' type='date'  class='search-entry' style='width:100px' /></td><td style='heigth:8px width:120px'><input id='plan' type='text' style='width:100px' class='search-entry' /></td><td style='heigth:8px width:120px'><input id='actual' type='text' style='width:100px' class='search-entry' /></td><td style='heigth:8px width:120px'> <a href='#' class='aui-button' onclick='javascript:add()'>add</a></td></tr></div>"
    } else {
        var date = $('#date' + id).text();
        var plan = $('#plan' + id).text();
        var actual = $('#actual' + id).text();
date=date.trim();
        date=date+'-01';
console.info(date);
date=date.trim();
console.info(date);
        strings = "<td style='heigth:8px width:120px'><div class='search-container'><input id='date' type='date' class='search-entry' style='width:100px'  value=" + date + "   /></div></td><td style='heigth:8px width:120px'><div class='search-container'><input id='plan' type='txet' style='width:100px' class='search-entry' value=" + plan + " /></div></td><td style='heigth:8px width:120px'><div class='search-container'><input id='actual' type='txet' style='width:100px' class='search-entry' value=" + actual + " /></div></td><td style='heigth:8px width:120px'> <a href='#' class='aui-button' onclick='javascript:update("+id+")'>update</a></td>"
  相关解决方案