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>
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”;
}
Edited by site staff: Inserted code tags