gpt4 book ai didi

javascript - 对象必需错误Javascript

转载 作者:行者123 更新时间:2023-12-03 09:10:28 25 4
gpt4 key购买 nike

我对用于Jira的以下代码有问题。当我运行代码时,我得到

第4行的对象必需错误

能否请你帮忙!批准者和受让人的值正确,因此它们没有问题

 <script type="text/javascript" charset="utf-8" id="priorityCustomFieldScript">


//utils(common)
var by_id=function(n){
var i=document.getElementById(n);
return { //error line
value:i.value,
set_value:function(v){i.value=v;}
};
};


function setSummaryAndSubmit(e){

e.preventDefault();
e.stopPropagation();

//utils
var id_set=function(n){
var v={};
v.a=function(x,y){v[x]=y;return v;};
v.g=function(){return v[by_id(n).value] || '';};
return v;
};

//approver
var by_id_11690=id_set('customfield_11690').
a('22468','205 SSNL SAP');

//assignee
var by_id_11690_1=id_set('customfield_11690:1').
a('22469','jpechea').
a('22470','amikusi');


var setter=(function(){
var d=new Date();
by_id('customfield_10146').set_value(d.getFullYear());
by_id('summary').set_value('ADI - '
+by_id('customfield_10146').value+' - '
+document.getElementById("customfield_10171").options[document.getElementById("customfield_10171").selectedIndex].text+' - '
+by_id_11690.g()+' - '
+by_id('customfield_10163').value);
//by_id('assignee').set_value(by_id_11690_1.g());


by_id('assignee-container').set_value(by_id_11690_1.g());
var selectedGlobalId;
selectedGlobalId=document.getElementById('assignee-container').value;
jQuery("#assignee").find('option').remove();
jQuery("#assignee").append("<option value='" + selectedGlobalId +"'>JIRA User</option>");
jQuery("#assignee").val(selectedGlobalId).attr("selected", "selected");




}());

//ok
//var form=this;
//form.submit();
jQuery("#customfield_10146").parents('form').submit();
}

jQuery(document).ready(function($) {

function hideSummaryAndAddSeverityHook(){



var row = document.getElementById("assignee-container");
if (row) {
row.style.display = 'none';
}

$('#customfield_10146').closest('div.field-group').hide();
$('#summary').closest('div.field-group').hide();


jQuery("input#issue-create-submit").click( function(event) {
setSummaryAndSubmit(event);});
jQuery("input#issue-edit-submit").click( function(event) {
setSummaryAndSubmit(event);});

}

var currentLocation = window.location.href;
if (currentLocation.indexOf('CreateIssue') > -1 || currentLocation.indexOf('EditIssue') > -1)
{


hideSummaryAndAddSeverityHook();
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {

hideSummaryAndAddSeverityHook();

});

}

});
</script>

最佳答案

如果未找到任何元素,则document.getElementById()返回null-您需要在代码中进行检查。您收到的错误表示我不是对象-因此document.getElementById()在您的一个调用中返回了null。

关于javascript - 对象必需错误Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23977196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com