我無法找到有關如何隱藏按鈕的任何文檔,當它填充的字段有一個值。我發現的所有參考文章都指的是隱藏一個按鈕,如果值爲空。如何在文本框值不爲空時隱藏按鈕
我需要「rmabutton」被禁用或隱藏的,如果「helpdesk_ticket_custom_field_rma_210279」已經與價值
<input type="button" id="rmabutton" onclick="RMA()" value="Generate RMA #">
<script type="text/javascript">
function RMA(){
//formatted day
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
//formatted month
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
//formatted year
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
//grab agent ID
var agent = $("helpdesk_ticket_responder_id").value;
//Isolate agent ID last 5 digits for use in RMA as agent number
var agent_short = agent.slice(5,10)
//grab ticket number and eliminate special characters
var ticket = $("ticket-display-id").innerHTML.replace(/[^a-zA-Z0-9 ]/g, "");
//parse new RMA # day-month-year-agent-ticket
var rma_number = ""+month+""+day+""+year+"-"+agent_short+"-"+ticket+"";
//replace RMA field contents with new RMA #
$("helpdesk_ticket_custom_field_rma_210279").value = rma_number;
}
</script>
另注,箱子需要顯示/隱藏取決於現場是否有一個值。 如果該框爲空 - 如果該框具有值,則顯示按鈕 - 隱藏按鈕 –
什麼是helpdesk_ticket ...?我在html中看不到它 – depperm
如果您發現有關如何在值爲空時隱藏按鈕的說明,只需將測試顛倒過來,並在具有值時將其隱藏起來。 – Barmar