Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-08-2003, 05:00 PM   #1 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
javascript function help..

im trying to make something that will swap out text when you click on a link. check out this page: http://msnbc.com/news/842500.asp about 3/4 of the way down.

i have been messing with the javascript on that site trying to figure it out, but its burried inside of many many many functions so im having a hardtime figuring it out.

here is where i have gotten from messing with their script:

PHP Code:
<script language=javascript>
function 
Swapcopy(dataname,nNextPg){
    var 
oData = eval(dataname);
    if (!
oData.nCurPage) { oData.nCurPage 0; }
    if (
nNextPg == oData.length) { nNextPg 0; }
    if (
document.layers) {
        var 
PopObj = eval("document.layers['poptext_" +dataname"']");
        var 
PopObj2 = eval("document.layers['poptext_" +dataname"2']");

        
PopObj.layers[oData.nCurPage].visibility="hidden";
        
PopObj.layers[nNextPg].visibility="show";
        if (
PopObj2) {
            
PopObj2.layers[oData.nCurPage].visibility="hidden"
            
PopObj2.layers[nNextPg].visibility="show"
        }
    }
    else if (
oBr.ie4) { 
        var 
PopObj = eval("document.all.poptext_" +dataname)
        var 
PopObj2 = eval("document.all.poptext_" +dataname+"2")

        
PopObj[oData.nCurPage].style.display="none";
        if (
nNextPg > -1) { PopObj[nNextPg].style.display=""; }
        if (
PopObj2) { 
            
PopObj2[oData.nCurPage].style.display="none";
            
PopObj2[nNextPg].style.display=""
        }
    }
    else if (
oBr.ns6) { 
        var 
PopObj = eval("document.getElementById(\"poptext_" +dataname+"\").childNodes");
        var 
PopObj2 = eval("document.getElementById(\"poptext_" +dataname+"2\")");
        
PopObj.item(oData.nCurPage).style.display="none";
        
PopObj.item(nNextPg).style.display="";
        if (
PopObj2) { 
            
PopObj2.childNodes.item(oData.nCurPage).style.display="none";
            
PopObj2.childNodes.item(nNextPg).style.display=""
        }
    }
    if (
nNextPg > -1) { oData.nCurPage nNextPg; }
}
</script>

</HEAD>

<BODY>

<script language=javascript>
 Products = new Array();
var i=0;
 Products[i++] = "<b>Product 1:</b> This is product 1";

 Products[i++] = "<b><b>Product 2:</b> This is product 2";

 </SCRIPT>

<a href="javascipt:Swapcopy('Products',0);">Product 1 </a> <br>
<a href="javascipt:Swapcopy('Products',1);">Product 2 </a> <br> 
am i close? anyone know of a simpler funtion to do something like that?

any help would be appreciated
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 03-09-2003, 06:02 PM   #2 (permalink)
saline
I am red.
 
saline's Avatar
 
Join Date: Feb 2003
Location: Cleveland, OH
Posts: 139
saline is on a distinguished road
wow

thats some nice code you got goin' there. One thing I might recommend is checking out a method (or property I can't remember) called "insideText". Unfortunatly I think it's IE specific and I don't know if it's a part of the w3c standard. But it might actually make the task you're looking at easier.

When I get home to my computer (instead of my girlfriends Imac) I'll look at the code and see what more I can't surmise about what you've done.
saline is offline   Reply With Quote
Old 03-09-2003, 06:35 PM   #3 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
heh, the code is borrowed from msn.com

they do some gnarly stuff with javascript.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Function jcramer83 HTML, XML, Javascript, AJAX 5 04-14-2003 06:12 AM
pass filename to function Blaqb0x Standard C, C++ 1 09-02-2002 10:12 PM
trouble calling auxiliary function in a class brtklt Standard C, C++ 0 07-18-2002 05:22 PM


All times are GMT -8. The time now is 02:42 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting