Duplicating Javascript To Work Twice On A Page

Sep 10, 2007

I'm trying to get a bit of javascript to work twice one a single page, what I'm trying to do is get a bunch of images scrolling, in 2 sets. If you may take a look here (The images within the "recent" and random "tabs").

What I did was duplicate the original code and edited the function names by adding "3" onto the end.


JavaScript Code:
gOverCWScroller = false;
 
function CWScroller(ulId, speed) {
 
    this.container = document.getElementById(ulId);
    this.container.Scroller = this;
    this.speed = speed;
 
    this.container.onmouseover = function(e) {
        gOverCWScroller = true;
    }
 
    this.container.onmouseout = function(e) {
        gOverCWScroller = false;
    }
 
    this.scroll = function() {
        if (gOverCWScroller == false) {
            var c = this.container.firstChild;
            var first = null;
            while (c) {
                if (c.tagName == 'LI') {
                    first = c;
                    break;
                }
                c = c.nextSibling;
            }
            var nodeSize = 78;  // Default
            var px = 0;
            nodeSize = first.clientWidth;
            if (first.style.marginLeft != '') {
                px = parseInt(first.style.marginLeft);
            }
            first.style.marginLeft = ( px - 1 ) + 'px'
            if ( parseInt(first.style.marginLeft) <= -(nodeSize) ) {
                first.style.marginLeft = &#390;px'
                this.container.removeChild(first);
                this.container.appendChild(first);
            }
        }
        setTimeout('document.getElementById('' + this.container.id + '').Scroller.scroll()', this.speed); 
    }
 
    setTimeout('document.getElementById('' + ulId + '').Scroller.scroll()', this.speed);
 
}


JavaScript Code:
gOverCWScroller3 = false;
 
function CWScroller3(ulId, speed) {
 
    this.container = document.getElementById(ulId);
    this.container.Scroller3 = this;
    this.speed = speed;
 
    this.container.onmouseover = function(e) {
        gOverCWScroller3 = true;
    }
 
    this.container.onmouseout = function(e) {
        gOverCWScroller3 = false;
    }
 
    this.scroll3 = function() {
        if (gOverCWScroller3 == false) {
            var c = this.container.firstChild;
            var first = null;
            while (c) {
                if (c.tagName == 'LI') {
                    first = c;
                    break;
                }
                c = c.nextSibling;
            }
            var nodeSize = 78;  // Default
            var px = 0;
            nodeSize = first.clientWidth;
            if (first.style.marginLeft != '') {
                px = parseInt(first.style.marginLeft);
            }
            first.style.marginLeft = ( px - 1 ) + 'px'
            if ( parseInt(first.style.marginLeft) <= -(nodeSize) ) {
                first.style.marginLeft = &#390;px'
                this.container.removeChild(first);
                this.container.appendChild(first);
            }
        }
        setTimeout('document.getElementById('' + this.container.id + '').Scroller3.scroll3()', this.speed);   
    }
 
    setTimeout('document.getElementById('' + ulId + '').Scroller3.scroll3()', this.speed);
 
}

This all works fine and dandy, however, I can only get one of the image sections to scroll. It's something to do with this:


HTML4Strict Code:
<script language="javascript" type="text/javascript">
CWScroller('scroller', 30, 'horizontal');
CWScroller3('scroller3', 30, 'horizontal');
</script>

If I leave out "CWScroller3('scroller3', 30, 'horizontal');" the recent section of images will scroll but the random images wont. If I put in "CWScroller3('scroller3', 30, 'horizontal');" it'll overwrite the the original recent section, and that won't scroll.

View 2 Replies


ADVERTISEMENT

Duplicating A CSS/ Javascript Slider

Jun 13, 2007

The problem I have is that on it's own my slider is perfectly happy sliding up and down and firing values off via an AJAX call, but how can I logically duplicate the slider and relevant code so that I can have more than 1? Code:

View 4 Replies View Related

JQuery :: Duplicating A Flash Gallery

Dec 8, 2010

I was just hoping that someone might be able to point me in the right direction of what to use? Or if it is even possible - I have seen many galleries but not one quite liek this - but surely it must be doable?

View 1 Replies View Related

Duplicating Sets Of Triple Drop Down Menu?

Jul 11, 2011

I need another few more sets of the triple drop down menu same as the below script... (Scenario: creating like a online shopping order form, where customers can have multiple orders.)

<script type="text/javascript">
/*
Triple Combo Script Credit

[code].....

View 14 Replies View Related

JQuery :: Form Wizard Not Working After Duplicating Steps?

Sep 2, 2010

I had a problem with the jquery formwizard plugin, when trying to add new steps by this code creates error in a sense that I can't click next, because the validate plugin validates the next form, even though the user didn't go to the next step yet.

Then all the other ajax drop down forms won't function properly in the new duplicated steps eventhough I used the .live() function What's wrong with my code? About form wizard, it divides your one form into alot of parts using span id as the name of the separate page and the class = step or step_submit as next step or submit page

<div id="frmWrapper">
<form id="signupForm" method="post" action="" class="bbq">
<div id="fieldWrapper">
<span class="stepinfo">Registration</span><br />
<span class="step" id="personal">

[Code]...

View 1 Replies View Related

Duplicating And Adding Show More Link Inside Hidden DIVs

Sep 6, 2009

I am trying to create a tell a friend script and add the ability for the users to send the email to more recipients than what is hard coded into the form. I have come up with this so far but is wont allow me to let the user 'show more email fields' a second time. I dont know how to write the javascript to allow this? When I tried duplicating the divs and adding a 'show more' link inside the first hidden div it just showed both sets when I clicked.

PHP Code:
<html><head><title>Example</title>
<script type="text/javascript">
function showDivs(){
var arr = document.getElementsByTagName('div')
for(var i=0; i<arr.length;i++){
arr[i].style.display = (arr[i].style.display == 'none')? 'block':'none';
}}
</script> .....

View 3 Replies View Related

Javascript Won't Work

Jul 20, 2005

I did a clean install of Windows XP on my computer and my javascript will
not work. I've tried all types of browsers, I've download the Service pack
1 for XP and IE. I have download java from Sun, which I know is not
javascript but it could not hurt. I have done everything I know of to fix
this problem but still Javscript will not work on my windows XP. I don't
know where to turn from here, Microsoft surely does not have any info about
on their website....

View 4 Replies View Related

JQuery :: Incorporate Two Files - If The Main Js Is On The Page Part Of The Page Does Not Work?

Jun 22, 2011

I am trying to incorporate two javascript files (using jQuery) and they are creating a conflict.If the main js is on the page part of the page does not work. If I do not include it my menu and some related features do not work correctly.One code is long so here is the link to it: *I removed Link* (this is the main code for the menu etc)The other js is:

$(document).ready(function(){
Engine.Initialize();
if( !$('body').hasClass('index') && !$('body').hasClass('homepage') ) {[code]....

View 2 Replies View Related

Works In A Html Page But Doesnt Work In Aspx Page?

Apr 7, 2010

I have a html document when i run in Internet explorer i am getting the desired output(j query working fine). But i copy pasted the same code in aspx page...the same code is not working properly...

View 9 Replies View Related

Javascript Work In NN/Mozilla

Jul 20, 2005

could you kindly help me to solve a compatibility problem that involves
Internet Explorer and NN/Mozilla.

I created a html page that contains a form (its name is "Modulo") and some
text boxes. After clicking on a button, a popup appears.
I tried to modify the text of "Testo" textbox from the popup windows by
using the following javascript code:

window.opener.Modulo.Testo.value=window.opener.Mod ulo.Testo.value + " This
will be added to Testo textbox!";

The code is correctly run by Internet Explorer and the "Testo" textbox in
the calling html page is successfully updated.

When I try to open these pages with Mozilla, the javascript code that should
update the textbox is ignored. How can I solve this problem?

View 2 Replies View Related

Javascript Won't Work In Firefox / What To Do?

Nov 8, 2010

Code... I have this simple script in the head of my html file. It works just fine in IE but not firefox.

View 5 Replies View Related

Trying To Get Two Javascript Statements To Work Together...

Nov 28, 2001

<script language="javascript">
<!--
self.location.href='#add'
document.addform.txtTitle.focus();
//-->
</script>

the self.location.href='#add' goes to a html anchor on the page, and the focus is supposed to set the cursor inside the first textbox when the statement is run.

if i run it as is, it will go to the anchor like its supposed to, but won't put the cursor in the textbox. if i comment out the first statement, it will put the focus on the textbox.

View 3 Replies View Related

Javascript Onclick Function Won't Work

Jul 23, 2005

I bringing up a list of movies in a separate window where each one has an
"onclick" function which is suppose to call a procedure and pass in the
variables and display the details of the selected record. When I click on a
record nothing happens. Code:

View 2 Replies View Related

Javascript Doesn't Work In Firefox

May 10, 2007

I have a problem with a Javascript, which doesn't works in Firefox
You can have a mouse over the 2 first pictures, but after the second
picture has moved over the screen, nothing is happening when you move
the mouse over the slideshow The source code:

View 2 Replies View Related

Why This Javascript Function Does Not Work On IE5, But Works On IE6?

Jul 20, 2005

function CheckImageBtn(eleName,sortfield)
{
document.forms[0].sortby.value=sortfield;
document.forms[0].txtIsHrefClick.value = 'Y'

var objElem;
objElem=eval("document.all."+eleName);
objElem.focus();
objElem.click();
return true;
}

View 1 Replies View Related

Javascript Doesn't Work Across Proxy

Jul 20, 2005

Sorry if this isn't exactly the right NG for this, but I thought you guys would know better than anyone else.

I have 2 computers networked. The internet connection is dial-up, and I'm using ezProxy to share the connection. Both computers are Win98,and both have IE6.0.

The main PC works perfectly, but the second PC's browser doesn't recognize Javascript at all! I've gone through every setting imaginable, and haven't found any reference to Javascript that was
incorrect.

Anybody have an ideas?

View 1 Replies View Related

How To Get Vbscript And Javascript Variables To Work Together

Feb 4, 2005

I'm having a problem getting javascript and vbscript to place nicely together. Here is what I want to do:

I'm getting values from my database for different exam types. Here are some sample values:

Exam Type1
Exam Type2
Exam Type3

Here is how I get the values in vbscript: Code:

View 5 Replies View Related

Javascript Style Options Don't Work With Forefox

Oct 28, 2005

Ik want 3 radiobuttons (from the same group) to be hidden. They may appear when I check a checkbox in the same form.

When I put the radiobuttons al in 1 DIV, and use style='visibility='hidden' or display='none' with an onclick() it works fine with IE.

The problem is that mozilla firefox doesn't hide the elements.

Someone knows the solution?

View 4 Replies View Related

CSS A:hover Doesn't Work After JavaScript BackgroundPosition

Aug 28, 2007

I have a menu done in CSS. When you mouse over the menu i change the background position in order to display the 'hover' state. I'm using javascript to show/hide <div> when you click on a button to display proper content without reloading the page (Like a tab menu).

To display the menu in a 'hover' state when you have clicked, i use also javascript to move the background position so it stays on the hover state. But when i mouse over my other menu, they do not apply the CSS anymore.

Here is the JS i use on a 'onclick':

function menu()
{
document.getElementById('menu2').style.backgroundPosition = 'center 0'
document.getElementById('menu1').style.backgroundPosition = 'center -48px'
}

I guess it have something to do with the fact that i alter the CSS with the JS. But anyone know how to fix this without having to create my mouseover with JS and keep it in CSS?

View 3 Replies View Related

JavaScript Form Validation Doesn't Work In Netscape

Jul 20, 2005

My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE.

I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes because then it didn't work in IE.

How can I enable this javascipt form validation to work in Netscape? When I use netscape, none of the alert boxes appear. It submits the form without validating anything.

In IE, I get all the alert boxes and everything is validated.

View 7 Replies View Related

Javascript To Make A Page Your Home Page

Feb 14, 2006

When someone comes to my site I would like to check to see if their
homepage is set to my site. If it is then nothing is done. If it is
not then I'd like a link to appear that asks if they'd like to set
their home page to my site.

Can this be done? If so can someone post the code to do it?

View 5 Replies View Related

Javascript Popup Page On Page Load

Sep 8, 2007

I am trying to do a popup window, which will load when the page loads. Using the onLoad in the <Body> tag. However it doesn't seem to be working. Also when the popup loads there will be a form which the user selects an option and the form is sent to a email address with the answer chosen and then the popup closed. Code:

View 7 Replies View Related

Web Page Refuses To Work In IE8?

Oct 29, 2011

I'm trying to code a website that will read data from an Excel file (stored either locally or elsewhere) and input a row of data (searched based on a Drop-Down List) into a table on the web page itself. Every time I open the page (it's currently stored on my local drive, on a laptop running Windows 7) in IE8, though, I get the error "Automation Server Can't Create Object" and nothing happens. The Excel file doesn't get opened and the table is blank. Thing is, though, I tried opening the same web page on another computer with IE6 and Windows 2000, and the Script works perfectly there.

I've been searching for a solution to this for a week, and some people suggested elsewhere that it's a problem with IE8's security settings. I lowered them as far as they'll go and enabled Running the Script Not Marked As Safe for all possible zones, same result, the Script refuses to run with the "Automation Server Can't Create Object" error. Here's the applicable lines of code:

function loadData() {
// try {
var Excel, Book;[code]...........

I'm completely stumped, everyone. Is it some obscure setting I'm forgetting to check in IE8, is my Java not fully updated, or what is it? Again, it works perfectly on my old Windows 2000 w/ IE6 computer, but not on a recent Windows 7 laptop with IE8.

View 3 Replies View Related

How Do I Get 2 Scripts To Work On A Page?

Oct 19, 2005

I have 2 scripts which I need to use on my webpage. Both scripts use the "window. command and this is causing a conflict between them.

I am aware that I can remove the "window. command and put it into the "<body event to stop conflicts, but how do get both to work when the "window. is the same for both scripts? I know I can't do "<body

View 2 Replies View Related

Using Two Scripts On Same Page / But Can Only Get One To Work?

May 26, 2011

I am using Lightbox to display gallery images and Colorbox to contain a web form. If I create separate pages for each they work separatly, but can only get one or the other to work on the same page.I don't want to change the scripts I'm using to different ones, I would like to keep them the same but just have them work together. I feel that this article is what I need to solve my problem and have played around with the code given and I obviously am not doing it right because I can't get it to work at all.

If you click 'Contact' the modal window using Colorbox works fine. However, clicking the top row of images should make them display in Lightbox.If somebody could tell me specifically what I need to do, that would be great.

View 6 Replies View Related

Code To Submit The Page Does Not Work Sometimes In IE?

Dec 2, 2010

I have a jsp which has a function gets called during the page unload. This jsp has a form with an action attribute to one servlet.
below the code snippet.

---- Java script code ---
function logoff() {
document.forms["FormName"].target="_self";[code]...

But this resulted in script error while loading the page "object does not support this method or property" at line where document.observe is there.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved