SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    writing a variable into a div tag? (I think)?

    I have a function that generates the code I want from form input.
    Beneath the form I want to create a div tag and write out the results from the form input.

    How would I go about doing this?

    How would I go about passing the results from the function (e.g. function newCode() {.......(code)... var scroll = X }
    Then I want to write out X in a div tag?

  2. #2
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.write:"<div>" + x + "</div>";

    should work...
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  3. #3
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    don't think i explained myself good enough:

    Here's what I have:
    www.meztec.com/test/popTest.html

    This works, but what I want to do is: when generate code is clicked it writes the response into a layer below the form..that way the user never leaves the form.

    Any ideas?

  4. #4
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function toDiv(id,text){
    if (document.getElementById) document.getElementById(id).innerHTML = text;
    else if (document.all) document.all[id].innerHTML = text;
    else if (document.layers){
    document.layers[id].document.open();
    document.layers[id].document.write(text);
    document.layers[id].document.close();
    }
    }

    I think that'll work.

  5. #5
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think i am following you: let me check:

    1: This function would be included in the head.

    2: the Parameters: id would be my declared style layer. (would that need positioned?)

    & text would be a global variable with the string that I want to write out.

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anarchos...this is one of the things that really holds me back when doing Javascript. How do you know those elements?

    For example, is innerHTML a DOM element or is that something that you just made up? If it IS a DOM element, then where can I find a complete list of elements. I want to learn how to do some dHTML things, but I can't for the life of me figure out how to reference a specific element on the page.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  7. #7
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    creole:

    .innerHTML is a property of the div element.
    divId.innerHTML = X

  8. #8
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now see...how did you KNOW that. That is what I want to know. Where can I find a reference for DOM elements. Something mega-comprehensive preferably.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  9. #9
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here's what I use: the most comprehensive book i've found:

    Dynamic HTML by O'reilly

    Basically has a complete DOM reference and CSS reference.

  10. #10
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://anarchos.xs.mw/newlinks.phtml?cat=16 has the sites that I use. DynDuo was the best help at DHTML; now I'm using DynAPI2, which makes DHTML a hell of a lot more fun. I don't know of any comprehensive references, but Microsoft has a very nice one for IE.

  11. #11
    SitePoint Guru
    Join Date
    Sep 1999
    Location
    Singapore
    Posts
    854
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by creole
    For example, is innerHTML a DOM element or is that something that you just made up? If it IS a DOM element, then where can I find a complete list of elements. I want to learn how to do some dHTML things, but I can't for the life of me figure out how to reference a specific element on the page.
    innerHTML is IE-specific. I think Mozilla implements it too, due to popular demand, but it is not strictly DOM-compliant.

  12. #12
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Creole,

    Checkout the documentation at Netscape. The client-side JavaScript reference is downloadable in pdf/zip-html format.

    HTH
    Last edited by isotope235; Jun 30, 2001 at 16:20.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •