/    Sign up×
Community /Pin to ProfileBookmark

Document.getElementById return null IE but working fine in Edge and firefox

I am getting undefined value while returning
document.getElementById() but the same code is executed successfully
in firefox and Edge browser tried using window.onload and addlistener

but getting the same error
found a couple of similar questions but the suggested solutions don’t

work out in my case
below is my code which i have written

JSP page:

[code]<div id=”ADDBUTTON” style=”vertical-align: bottom;margin-left: 10px;display: none;”>
<label style=”text-align: center;” class=”titleblue_s4″ >Add Part Description</label><br>
<div class=”Table”>
<div class=”Row”>
<div class=”Cell”><label class=”graylabel2″>Enter Part:</label><font color=”red”>*</font></div>
<div class=”Cell”><s:textfield cssClass=”text” name=”partEntered” id=”partEntered” value=”%{partEntered}” theme=”simple” size=”50″ onkeydown=”return validatetext(event);” onkeypress=” return validatetext(event);” />
</div></div><div class=”Row”>
<div class=”Cell”><label class=”graylabel”>Part Description:</label></div>
<div class=”Cell”> <s:textfield cssClass=”text” name=”addpartdescrp” id=”addpartdescrp” value=”%{addpartdescrp}” theme=”simple” size=”50″ maxlength=”200″ onkeydown=”return validatetext(event);” onkeypress=” return validatetext(event);”/>
</div>
</div>
<br>
<div class=”Row”> <div class=”Cell”></div><div class=”Cell”><input type=”button” id=”addbutton” value=”Submit” onclick =”Acttt(this.value);” /></div></div>
</div>
</div>[/code]

Javascript:

[code]function Acttt(str)
{
alert(str);
//var EmptyPart=document.getElementById(“partEntered”).value;
var EmptyPart1=document.getElementById(“partEntered”);
var EmptyPart=EmptyPart1.value;

alert(EmptyPart);

if(!EmptyPart.match(/S/)) {
alert (‘Empty value is not allowedd’);
return false;

}
if(typeof EmptyPart == null || typeof EmptyPart ===””){
//if(EmptyPart == null || EmptyPart ===””){
alert(‘Please enter Part value’);
return false;
}

var ddlArray= new Array();
var ddl = document.getElementById(‘listparts’);
for (i = 0; i < ddl.options.length; i++) {
ddlArray[i] = ddl .options[i].value;

//if(ddlArray[i] == EmptyPart){
if(ddlArray[i] == EmptyPart.trim()){

alert(‘Duplicate part Entered please enter Unique Part’);
return false;
}
}
document.fform1.submit();
document.getElementById(“loading”).style.display=”inline”;
}[/code]

Edited by site staff: Inserted code tags

to post a comment
Full-stack Developer

0Be the first to comment 😎

×

Success!

Help @vish559 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...