Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 02-07-2007, 06:33 PM Load results script
John84's Avatar
Skilled Talker

Posts: 64
Name: John
Trades: 0
Before I go on, lemme just say that I don't know squat about javascript. That being said...

I am using the following javascript to load results onto my page...

HTML Code:
var xml = xmlObject();
var url;
var button;
var result;
function xmlObject () {
    if (typeof XMLHttpRequest == 'undefined') {
        objects = Array(
            'Microsoft.XmlHttp',
            'MSXML2.XmlHttp',
            'MSXML2.XmlHttp.3.0',
            'MSXML2.XmlHttp.4.0',
            'MSXML2.XmlHttp.5.0'
        );
        for (i = 0; i < objects.length; i++) {
            try {
                return new ActiveXObject(objects[i]);
            } catch (e) {}
        }
    } else {
        return new XMLHttpRequest();
    }
}
function resultElement () {
    if (!document.getElementById('result')) {
        result = document.createElement('div');
        result.id = 'result';
        document.body.appendChild(result);
    }
}
function handleResults () {
    if (xml.readyState == 4) {
        if (xml.responseText == 'url.blank') {
            result.innerHTML = 'Enter a valid URL';
        } else {
            result.innerHTML = xml.responseText;
        }
    } else {
        result.innerHTML = 'Loading..';
    }
}
function getResults () {
    resultElement();
    xml.open('get', 'results.php?url=' + escape(url.value));
    xml.onreadystatechange = handleResults;
    xml.send(null);
}
function loadHandler () {
    url = document.getElementById('url');
    button = document.getElementById('button');
    button.onclick = getResults;
}
window.onload = loadHandler;
problem is, the results are loading at the bottom of my page. Is there a way to make it load in a specified div?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
John84 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-07-2007, 10:18 PM Re: Load results script
John84's Avatar
Skilled Talker

Posts: 64
Name: John
Trades: 0
ive narrowed it down to this portion...

HTML Code:
function resultElement () {
    if (!document.getElementById('result')) {
        result = document.createElement('div');
        result.id = 'result';
        document.body.appendChild(result);
    }
}
... instead of creating a div I would like it to load on an existing div

Test page is here
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
John84 is offline
Reply With Quote
View Public Profile
 
Old 02-13-2007, 06:46 AM Re: Load results script
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
document.getElementById('result').innerHTML = result
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Load results script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40399 seconds with 12 queries