Javascript does not recognise dynamic div content

General Tech Learning Aids/Tools 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I have a script i have been battling with now for like a week.

I have a page which has a div with id ("content"). Now I loaded some content, a form contained in a div tag to be specific, into this div VIA Ajax, and it is displaying fine

Now, the challenge is - When the form is submitted, Im am calling a function that will disable all the field on the element in that div tag. I always get the error "undefined".

It seems that the div, that i brought in to the page isn't recognized by javascript..

I have searched google, bing, yahoo..i just havent found the solution yet...

Please, what do I do??

I have included the code below --

+++++++++ The code below for my external javascript file

++++++++++++++++++++

// JavaScript Document

var doc = document;
var tDiv;
var xmlHttp;
var pgTitle;

function getXMLObj(){
        if (window.XMLHttpRequest){
          // code for IE7+, Firefox, Chrome, Opera, Safari
                Obj = new XMLHttpRequest();
          }
        else if (window.ActiveXObject){
            // code for IE6, IE5
                Obj = new ActiveXObject("Microsoft.XMLHTTP");
          }
        else{
                alert("Your browser does not support Ajax!");
        }
        return Obj;
}


function loadCont(toLoad, view){
    doc.getElementById('loadBlank').innerHTML = '
Processing Request...
'
; var url; switch(toLoad){ case 'CI': pgTitle = "Administration - Company Information"; url = "comp_info.php?v=" + view + "&sid=" + Math.random(); break; case 'JB': pgTitle = "Administration - Jobs"; url = "jobs.php?v=" + view + "&sid=" + Math.random(); break; case 'US': pgTitle = "Administration - Users"; url = "users.php?v=" + view + "&sid=" + Math.random(); break; case 'EP': pgTitle = "Administration - Employees"; url = "emp.php?v=" + view + "&sid=" + Math.random(); break; case 'AP': pgTitle = "Administration - Recruitments"; url = "applicants.php?v=" + view + "&sid=" + Math.random(); break; case 'JV': pgTitle = "Administration - Recruitments"; url = "jobvacancy.php?v=" + view + "&sid=" + Math.random(); break; } xmlHttp = getXMLObj(); if (xmlHttp !== null &&
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.