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 779139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:52:50+00:00 2026-05-14T19:52:50+00:00

I have these lines in my html head section <script type=text/javascript src=../behaviour/location.js></script> <script type=text/javascript

  • 0

I have these lines in my html head section

<script type="text/javascript" src="../behaviour/location.js"></script>
<script type="text/javascript" src="../behaviour/ajax.js"></script>

When I use either in isolation, the code in the external files executes as expected.

However, when I use both, I find that neither works correctly. What do I need to do to fix this?

location.js

// JavaScript Document

function addLoadEvent (func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function () {
            oldonload();
            func;
        }
    }
}

//county changer
function countyUpdate (message) {

    var name = message.getAttribute("name");
    var check = message.checked;
    var countyId = message.getAttribute("id");
    var countyId = countyId.split("_")[1];
    var innerpost = document.getElementById("innerpost_"+countyId); 
    var checks = innerpost.getElementsByTagName("input");

    for (var i = 0; i< checks.length; i++) {
        if (checks[i].checked == true && check == true) {
        checks[i].checked = false; 
        }
    }

}

//postcode changer
function postcodeUpdate (message) {
    var parent = message.parentNode.parentNode.getAttribute("id").split("_")[1];
    var county = "county_"+parent;
    var checkbox = document.getElementById(county);
    var checked = message.checked;

    if (checked == true) {
        checkbox.checked = false;
    }


}

//get a dynamic list of al postcode checkboxes
function getCounties () {
var county = document.getElementsByTagName("input");


for (var i = 0; i< county.length; i++) {
var check = county[i].getAttribute("type");

if (check == "checkbox") {  
var name = county[i].getAttribute("name");
var parent = county[i].parentNode.parentNode.getAttribute("id");
var parent = parent.split("_")[0];

//action for county
if (parent != "innerpost") {
county[i].onclick = function() { countyUpdate(this); };

    }//if


    //action for postcode
    if (parent == "innerpost") {
    county[i].onclick = function() { postcodeUpdate (this); }; 
    }//if

    }//if
    }//for
    }//function

    addLoadEvent (getCounties);

ajax.js

function loadXMLDoc()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","cart.php",true);
xmlhttp.send();
}

And this is the inline code to activate the second file:

<button type="button" onclick="loadXMLDoc()">Change Content</button>

When I try using both files together, I don’t seem to be able to use any functions (not even simple alerts wrapped in a function).

  • 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-14T19:52:51+00:00Added an answer on May 14, 2026 at 7:52 pm

    My bet is that you’re getting a mess out of that window.onload= juggling. I suggest you use the standard window.addEventListener() interface (check for its existance and use window.attachEvent() when the standard interface is missing if you want to support IE too). This should also guarantee that the onload functions get executed in the same order as the scripts that set them. Something like:

    if (window.addEventListener) {
      window.addEventListener('load', somefunc, false);
    } else if (window.attachEvent) {
      window.attachEvent('onload', somefunc);
    } // else, no way to add multiple onload handlers
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML file containing these lines - <script>PrintFileURL("13572_BranchInformationReport_2012-06-29.xml","13572_BranchInformationReport_2012-06-29.zip",0,"184277","Jun 29 1:30","/icons/default.gif")</script> <script>PrintFileURL("13572_BranchInformationReport_2012-07-02.zip","13572_BranchInformationReport_2012-07-02.zip",0,"184302","Jul 2
I have the following html files: <html> <head> <style type=text/css> .table-striped { padding: 0;
I load in HTML pages via Ajax. These files have no <title><head><body> tags, etc.
I have these (sample) lines in a HTML-file: test.ABC.test test.ABCD.test test.ABCE.test And this Ant
I have some html files and want to extract only lines with containing these
So I have these lines of javascript code that I need to remove all
<html> <head> <meta name=viewport content=width=device-width/> <title>HAHAHA</title> <STYLE TYPE=text/css media=screen> * { padding: 0; margin:
I have the following HTML with many of these kinds of links: <a class=button
I have these lines in my actionCreate : if (isset($_POST['DpcioCbn'])) { print_r($_POST['DpcioCbn']); $model->attributes =
I have these lines of code in a command line project in VS2010 c++.

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.