Nesting Javascripts?

Discussion in 'Javascript' started by GarryJones, Aug 23, 2008.

  1. GarryJones

    GarryJones Guest

    Can I nest javascript to open a hidden DIV tag on a DIV tag that is
    itself opened by javascript?

    I have a javascript to decide which DIV tag is visible. (Code A)

    In one of these DIV tags (mck04) I have a button to show a hidden
    form. (Code B)

    Code B works stand alone on its on html page but I get "element not
    found" when I place the link to it in another DIV tag which in itself
    is opened by Code A.

    Code A
    ***************************************************************
    var ids=new Array('mck01','mck02','mck03','mck04','mck05');

    function switchid(id){
    hideallids();
    showdiv(id);
    }

    function hideallids(){
    for (var i=0;i<ids.length;i++){
    hidediv(ids);
    }
    }

    function hidediv(id) {
    if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById(id).style.display = 'none';
    }
    else {
    if (document.layers) { // Netscape 4
    document.id.display = 'none';
    }
    else { // IE 4
    document.all.id.style.display = 'none';
    }
    }
    }

    function showdiv(id) {
    if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById(id).style.display = 'block';
    }
    else {
    if (document.layers) { // Netscape 4
    document.id.display = 'block';
    }
    else { // IE 4
    document.all.id.style.display = 'block';
    }
    }
    }

    *****************************
    This is Code B

    function InsertContent(tid) {
    if(document.getElementById(tid).style.display == "none") {
    document.getElementById(tid).style.display = "";
    }
    else {
    document.getElementById(tid).style.display = "none";
    }
    }
    **********************************

    This is the code to show the mck04 tag
    <a href="javascript:switchid('mck04');">Details</A>

    The mck04 div is displayed and in it I have some details of a sporting
    event. The idea is if they want to sign up they open the form (show1)
    whilst remaining within the mck04 tag.

    <div id="show1" style="display: none">
    (The form code is here)
    </div>

    This is the link within DIV mck04 which should open show1
    <a href="javascript:InsertContent('show1');">Click here to sign up</a>

    Any help greatly appreciated

    Garry Jones
    Sweden
    GarryJones, Aug 23, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob Walton
    Replies:
    0
    Views:
    904
    Bob Walton
    Jul 19, 2003
  2. =?Utf-8?B?VGlnZ2Vy?=

    Using JavaScripts in ASP.NET, please help...

    =?Utf-8?B?VGlnZ2Vy?=, Jan 11, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    648
    MWells
    Jan 12, 2005
  3. Replies:
    0
    Views:
    419
  4. Nico Schuyt
    Replies:
    2
    Views:
    419
    Nico Schuyt
    Jul 27, 2003
  5. Trans
    Replies:
    10
    Views:
    288
    Sean O'Halpin
    Sep 16, 2005
Loading...

Share This Page