Results 1 to 4 of 4

Thread: Is this right?

  1. #1
    Join Date
    Feb 2007
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is this right?

    Solved:
    HTML Code:
    <script ...>
    function Something(ID){
    	if(document.getElementById){
    		var GetResultId = document.getElementById(ID);
    	}
    	else if (document.all){
    		var GetResultId = document.all[ID];
    	}
    	else if (document.layers){
    		var GetResultId = document.layers[ID];
    	}
    	else{
    		return false;
    	}
    GetResultId.innerHTML = "Whatever";
    
    }
    
    
    </script>


    Also is it:

    function Something(form){
    document.forms[form].whatever...

    }
    Last edited by Tabo; 08-02-2007 at 05:15 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The document.layers part won't work, but that is rarely used. Not since NN4, I believe. The rest will work.

    See:

    http://www.quirksmode.org/js/layerwrite.html

    Added Later:

    This seems to also work out fairly well:

    Code:
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript">
    function Something(ID) {
    var text='whatever', d=document.layers||document.all||null;
    var x=d? d[ID] : document.getElementById? document.getElementById(ID) : null;
    if (document.getElementById)
    		x.innerHTML = '';
    if (document.layers){
    		x.document.open();
    		x.document.write(text);
    		x.document.close();
    	}
    else if(x)
    		x.innerHTML = text;
    return false;
    }
    </script>
    </head>
    <body>
    <div>
    <div id="blah"><layer name="blah"></layer><br></div>
    
    <a href="#" onclick="return Something('blah');">test</a>
    </div>
    </body>
    </html>
    Last edited by jscheuer1; 08-02-2007 at 02:23 AM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2007
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok and how about this:

    function Something(form){
    document.forms[form].whatever...

    }

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Tabo View Post
    Ok and how about this:

    function Something(form){
    document.forms[form].whatever...

    }
    What about it?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •