I am getting this JavaScript error, doing some research people are saying something about instantiating an object.
function generateRow() {
var i = pageCounter.getIP_count();
//common sense counting
i++;
var objNEWVIP = document.getElementById("IP_row_new");
var objMODIFYVIP = document.getElementById("IP_row_modify");
//common DOM elements
var memberNum = document.createTextNode('Member IP'+ i + '\u00a0');
var brNode = document.createElement('br');
var nbspSpace = document.createTextNode('\u00a0');
var resolvesTextNode = document.createTextNode('Resolves: \u00a0');
//new_IP_Octet1_Element
var new_IP_Octet1_Element = document.createElement('input');
new_IP_Octet1_Element.setAttribute('type','text');
new_IP_Octet1_Element.setAttribute('maxlength','3');
new_IP_Octet1_Element.setAttribute('size','3');
new_IP_Octet1_Element.setAttribute('name','IP'+i+'_octet1');
new_IP_Octet1_Element.setAttribute('id','IP'+i+'_octet1');
new_IP_Octet1_Element.setAttribute('value','167');
new_IP_Octet1_Element.setAttribute('size','3');
new_IP_Octet1_Element.setAttribute('hostname','IP'+i+'_hostname');
new_IP_Octet1_Element.onchange = function () { resolveMe(this.id); };
//new_IP_Octet1_Element.setAttribute('onchange', 'resolveMe(this.id);');
//new_IP_Octet2_Element
var new_IP_Octet2_Element = document.createElement('input');
new_IP_Octet2_Element.setAttribute('type','text');
new_IP_Octet2_Element.setAttribute('maxlength','3');
new_IP_Octet2_Element.setAttribute('size','3');
new_IP_Octet2_Element.setAttribute('name','IP'+i+'_octet2');
new_IP_Octet2_Element.setAttribute('id','IP'+i+'_octet2');
new_IP_Octet2_Element.setAttribute('value','69');
new_IP_Octet2_Element.setAttribute('size','3');
new_IP_Octet2_Element = function () { resolveMe(this.id); };
//new_IP_Octet2_Element.setAttribute('onchange', 'resolveMe(this.id);');
//new_IP_Octet3_Element
var new_IP_Octet3_Element = document.createElement('input');
new_IP_Octet3_Element.setAttribute('type','text');
new_IP_Octet3_Element.setAttribute('maxlength','3');
new_IP_Octet3_Element.setAttribute('size','3');
new_IP_Octet3_Element.setAttribute('name','IP'+i+'_octet3');
new_IP_Octet3_Element.setAttribute('id','IP'+i+'_octet3');
new_IP_Octet3_Element.setAttribute('value','0');
new_IP_Octet3_Element.setAttribute('size','3');
new_IP_Octet3_Element = function () { resolveMe(this.id); };
//new_IP_Octet3_Element.setAttribute('onchange', 'resolveMe(this.id);');
//new_IP_Octet4_Element
var new_IP_Octet4_Element = document.createElement('input');
new_IP_Octet4_Element.setAttribute('type','text');
new_IP_Octet4_Element.setAttribute('maxlength','3');
new_IP_Octet4_Element.setAttribute('size','3');
new_IP_Octet4_Element.setAttribute('name','IP'+i+'_octet4');
new_IP_Octet4_Element.setAttribute('id','IP'+i+'_octet4');
new_IP_Octet4_Element.setAttribute('value','0');
new_IP_Octet4_Element.setAttribute('size','3');
new_IP_Octet4_Element = function () { resolveMe(this.id); };
//new_IP_Octet4_Element.setAttribute('onchange', 'resolveMe(this.id);');
//make SPAN for DNS reverse resolution
var reverseDNS_Element = document.createElement('span');
reverseDNS_Element.setAttribute('id','IP'+i+'_hostname');
reverseDNS_Element.setAttribute('name','IP'+i+'_hostname');
//output
if (document.getElementById('requesttype').value == "new") {
objNEWVIP.appendChild(memberNum);
objNEWVIP.appendChild(new_IP_Octet1_Element);
objNEWVIP.appendChild(nbspSpace);
objNEWVIP.appendChild(new_IP_Octet2_Element);
objNEWVIP.appendChild(nbspSpace);
objNEWVIP.appendChild(new_IP_Octet3_Element);
objNEWVIP.appendChild(nbspSpace);
objNEWVIP.appendChild(new_IP_Octet4_Element);
objNEWVIP.appendChild(nbspSpace);
objNEWVIP.appendChild(resolvesTextNode);
objNEWVIP.appendChild(reverseDNS_Element);
objNEWVIP.appendChild(brNode);
}
if (document.getElementById('requesttype').value == "modify") {
objMODIFYVIP.appendChild(memberNum);
objMODIFYVIP.appendChild(new_IP_Octet1_Element);
objMODIFYVIP.appendChild(nbspSpace);
objMODIFYVIP.appendChild(new_IP_Octet2_Element);
objMODIFYVIP.appendChild(nbspSpace);
objMODIFYVIP.appendChild(new_IP_Octet3_Element);
objMODIFYVIP.appendChild(nbspSpace);
objMODIFYVIP.appendChild(new_IP_Octet4_Element);
objMODIFYVIP.appendChild(nbspSpace);
objMODIFYVIP.appendChild(resolvesTextNode);
objMODIFYVIP.appendChild(reverseDNS_Element);
objMODIFYVIP.appendChild(brNode);
}
pageCounter.addMethod("ip_count"); //increment after adding row
}
generateRow() function gets called when a user clicks a button.
What object am I instantiating…and how do I do that?
I think the problem lies with
var objNEWVIP = document.getElementById("IP_row_new");
var objMODIFYVIP = document.getElementById("IP_row_modify");
But i am unsure how to create a new object at this location…
Here is the counter function
function counterObj(){
//object to keep track of all counts across all forms
this.ipCountTotal = 0;
this.dnsElementTotal = 0;
this.approverTotal = 0;
//input methods mapping
this.clear = clearing;
this.addMethod = add;
//retreval methods mapping
this.getIP_count = function() { return(this.ipCountTotal);};
this.getDNS_count = function() { return(this.dnsElementTotal);};
this.getApprover_count = function() { return(this.approverTotal);};
//addMethod
function add(strType){
switch(strType) {
case "dns_count":
this.dnsElementTotal++;
break;
case "ip_count":
this.ipCountTotal++;
break;
case "approver_count":
this.approverTotal++;
break;
} //end swtich strType
}
//clear all
function clearing(){
this.ipCountTotal = 0;
this.dnsElementTotal = 0;
this.approverTotal = 0;
}
}
Here is the declaration:
var pageCounter = new counterObj();
pageCounter.clear()
Here are the html DIVs
<div id="ip_row_new" title="please provide the ip address of each endpoint member.">
</div>
and…
<div id="IP_row_modify">
<!-- dynamically adds new rows -->
</div>
Here is the select statement in the HTML that the user will pick….
<select id="requesttype" name="requestType" onChange="checkF5Request(this.value);" tabindex="2">
<option value="...">...</option>
<option value="new">New Request</option>
<option value="modify">Modify Request</option>
<option value="delete">Removal Request</option>
<option value="iRule_redirect">iRule Redirect</option>
</select>
Here is the error:
Error: uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMHTMLDivElement.appendChild]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: https://request.psp :: generateRow :: line 358" data: no]
So your
new_IP_Octet2_Elementis a function:..which cannot be passed to
appendChild(), which requires a DOM node.I’m not sure what’s the point of this function, but if you remove it, the error on the
objNEWVIP.appendChild(new_IP_Octet2_Element);should go away.