+ Reply to Thread
Results 1 to 5 of 5

Thread: im looking for this Ajax Script

  1. #1
    medina's Avatar
    medina is offline x10 Addict medina is an unknown quantity at this point
    Join Date
    Nov 2006
    Location
    Cuernavaca
    Posts
    1,837

    im looking for this Ajax Script

    I am looking for script in AJAX who changes the dimensions of a DIV.

    im try to find it in google but nothing... please help me!
    ▐ Quieres Ganar $50 dólares totalmente gratis en menos de 24 horas? Visita este Post y ve como lograrlo
    http://x10hosting.com/forums/mercado/124800-gana-0-35-por-ser-mi-referido-unos-50-00-extra.html






  2. #2
    essellar's Avatar
    essellar is offline Community Advocate essellar has a spectacular aura about
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,153

    Re: im looking for this Ajax Script

    There is nothing Ajax-y about resizing an element. Ajax, by definition, means making a background request to the server. All you need is plain old JavaScript.

    Code:
    function resizeElement(div, height, width) {
        elem = (typeof(div) == "string") ? document.getElementById(div) : div;
        if (!div || typeof(div) != "object") {
            return false;
            }
        div.style.height = height;
        div.style.width = width;
        return true;
        }
    (Yes, I happen to like banner-style indents. So sue me.) There are still holes in this code -- I usually use something similar to Protoype's $() to fetch the element(s) with more sophisticated type checking, default assumptions and iteration where necessary (as when a collection is returned). Don't "search the web" for scripts, since you will probably have to modify something you don't understand in order to make it work on your page -- learn the language.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  3. #3
    smithee's Avatar
    smithee is offline x10Hosting Member smithee is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    NIMBY
    Posts
    45

    Re: im looking for this Ajax Script

    essellar, correct me if I'm wrong (as I haven't touched JavaScript for a while), but concerning this part of the code:

    HTML Code:
    elem = (typeof(div) == "string") ? document.getElementById(div) : div;
    ... shouldn't div.style.height = height; be elem.style.height = height; instead, as elem has been assigned the object information and perhaps not div? The same applies for div.style.width= width;.
    Last edited by smithee; 06-29-2010 at 04:44 PM.
    .

    Be nice to nerds. Chances are you’ll end up working for one. - Bill Gates

  4. #4
    essellar's Avatar
    essellar is offline Community Advocate essellar has a spectacular aura about
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,153

    Re: im looking for this Ajax Script

    Actually, that's the result of an editing error (the posted code was excerpted from something else). Should have read:

    Code:
    function resizeElement(div, height, width) {
        div = (typeof(div) == "string") ? document.getElementById(div) : div;
        if (!div || typeof(div) != "object") {
            return false;
            }
        div.style.height = height;
        div.style.width = width;
        return true;
        }
    Thanks for the sharp eyes -- but why would you change "div" to read "elem" in four places when changing "elem" to read "div" once would have done the same thing, and without introducing an unnecessary variable?
    Last edited by essellar; 06-30-2010 at 08:38 AM.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  5. #5
    smithee's Avatar
    smithee is offline x10Hosting Member smithee is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    NIMBY
    Posts
    45

    Re: im looking for this Ajax Script

    Yeah that's a good point, I suppose I've missed that whilst glancing over the provided code late last night.

    @medina... What essellar has provided should be sufficient enough to meet your requirements; no Ajax here needed at all. If you run into any more trouble, just post another message and we'll be happy to help.
    .

    Be nice to nerds. Chances are you’ll end up working for one. - Bill Gates

+ Reply to Thread

Similar Threads

  1. Need help getting ajax script to work
    By Fearghal in forum Programming Help
    Replies: 6
    Last Post: 12-12-2009, 02:11 PM
  2. Script para AJAX
    By brisati in forum General
    Replies: 0
    Last Post: 11-06-2007, 11:39 AM
  3. AJAX Labels Script
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-19-2007, 06:04 PM
  4. AJAX Labels XML Script
    By cuteboytm in forum Graphics & Webdesign
    Replies: 0
    Last Post: 09-19-2007, 12:55 PM
  5. AJAX Script
    By Brandon in forum Scripts & 3rd Party Apps
    Replies: 16
    Last Post: 05-09-2007, 04:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers