Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6873657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:05:47+00:00 2026-05-27T04:05:47+00:00

I am trying to figure out why my javascript that creates input elements on

  • 0

I am trying to figure out why my javascript that creates input elements on the fly via DOM is referencable in Firefox but not in IE 7 nor 8.

I have the following function triggered when a user clicks a button

function addEndPoint_intelDNS(){
    pageCounter.addMethod("endpoint_count");
    count = pageCounter.getendpoint_count();

    //endpoint IP and hostname labels
    var endpointIPText = document.createTextNode('Endpoint ' + count + ' IP: \u00a0');
    var endpointHostText = document.createTextNode('\u00a0 Endpoint ' + count + ' Hostname: \u00a0 ');
    var brNode = document.createElement('br');

    //endpoint InputIPBox
    var endpoint_IP_InputElement = document.createElement('input');
    endpoint_IP_InputElement.setAttribute('type', 'text');
    endpoint_IP_InputElement.setAttribute('id', 'endpoint_'+count+'_ip');
    endpoint_IP_InputElement.setAttribute('name', 'endpoint_'+count+'_ip');
    endpoint_IP_InputElement.setAttribute('maxlength', '15');
    endpoint_IP_InputElement.setAttribute('onChange', 'resolveMe(this.value,\u0022endpoint_'+count+'_name\u0022, \u0022ip\u0022);');


    //endpoint host inputbox
    var endpoint_HOST_InputElement = document.createElement('input');
    endpoint_HOST_InputElement.setAttribute('type', 'text');
    endpoint_HOST_InputElement.setAttribute('id', 'endpoint_'+count+'_name');
    endpoint_HOST_InputElement.setAttribute('name', 'endpoint_'+count+'_name');
    endpoint_HOST_InputElement.setAttribute('size', '35');
    endpoint_HOST_InputElement.setAttribute('onChange', 'resolveMe(this.value,\u0022endpoint_'+count+'_ip\u0022, \u0022name\u0022);');

    //output
    document.getElementById('intelDNS_endpoints_codeblock').appendChild(endpointIPText);
    document.getElementById('intelDNS_endpoints_codeblock').appendChild(endpoint_IP_InputElement);
    document.getElementById('intelDNS_endpoints_codeblock').appendChild(endpointHostText);
    document.getElementById('intelDNS_endpoints_codeblock').appendChild(endpoint_HOST_InputElement);
    document.getElementById('intelDNS_endpoints_codeblock').appendChild(brNode);

Please ignore the pageCounter object, it is simply an object that keeps track of how many inputs the user will be supplying.

As you can see there is a onChange event attribute added to each of the 2 input text boxes (InputIPBox and host_inputbox) They are practically identical so I will supply one of the functions

function resolveMe(val, loc_id, type){
    alert(val);
    switch(type){
        case "ip":
                resolveIP2DNS(val, loc_id);
            break;
        case "name":
                resolveDNS2IP(val, loc_id);
            break;
    }

}

function resolveIP2DNS(ip, loc){
    doclocation = loc;
    var ajaxRequest; //initialize ajax object
    var browser = navigator.appName; //find the browser name
    if(browser == "Microsoft Internet Explorer"){
        /* Create the object using MSIE's method */
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        /* Create the object using other browser's method */
        ajaxRequest = new XMLHttpRequest();
    }

    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4)
        {
            // Get the data from the server's response
            //what on this page is changing
            var xmlRes=ajaxRequest.responseXML.documentElement;
            try {
                var dns = xmlRes.getElementsByTagName('DNS')[0].firstChild.nodeValue;
            }catch (err){
                dns = "Not Resolvable";
            }
            //output to location in page
            document.getElementById(doclocation).value = dns;   
        }

    }
    ajaxRequest.open("GET", "/ajax.psp?ip2DNS=" + ip, true);
    ajaxRequest.setRequestHeader('Content-Type', "text/xml");
    ajaxRequest.send(null);
}

The ajax.psp page works perfectly and this function works when called for different parts of my site, So i know it is receiving the desired resolution values.

So I am quite stumped, because it works perfectly in Firefox, but not in IE..Also further debuggin I see that the onchange event never goes to the first function in IE(hence the alert never gets popped).

Let me know what you all think…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:05:48+00:00Added an answer on May 27, 2026 at 4:05 am

    Don’t use “setAttribute()” to set things that should be properties on the DOM node. Thus, set the “onchange” handler with

    endpoint_IP_InputElement.onchange = function() {
      resolveMe(this.value, 'endpoint_'+count+'_name', 'ip');
    };
    

    That will work with Firefox and Chrome etc. too.

    edit — hold on – we’re going to have to make sure this is properly bound in the function. I’m not sure it’ll be bound automatically in older IE, so I’ll check.

    edit again — yup it should be fine. When your function is called, this will be the changed <input> node.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Ribbit javascript api and trying to figure out how not
I'm not a JavaScript guru (yet). I am trying to figure out a way
i am trying to figure out how to create a javascript alert box asking
I'm trying to figure out if there is a way (using JavaScript, or jQuery
I am trying to figure out certain memory leak conditions in javascript on a
I am trying to figure out how to click all three of these (not
I believe that datetime_select is black magic. What I'm really trying to figure out
i'm trying to figure out how much i can use of the javascript language
I am trying to figure out how to process XML in java script So
Trying to figure out an equation to get the current group a page would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.