473,320 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

passing parameter problems

Hi, I'm designing a website in dreamweaver and I'm using JavaScript to
slide text across the page. The text is contained in <div> tags. I
have designed a function which can move two of the div tags across the
screen. I use the timer to manage the movement of the text across the
screen. I would like redesign that function so that it can move any
amount of div blocks across the screen. To do this, I need to pass a
parameter to the function moveParas()

The following set up works fine, calling moveParas which moves two div
code blocks across the screen:

function window_onload()
{
window.setInterval("moveParas()",1);
}

<--moveParas() is located at the bottom of the screen-->
---------------------------------------------------------------------------------------------------------------------------
I have tried to change moveParas() so that it can accept paramaters. I
have tried to pass it variables and hardcoded coded value, but this is
not working. I have of course altered the function itself to accept a
parameter.

function window_onload()
{
var dog = false;
window.setInterval("moveParas(dog)",1);
}

I know the code is causing errors because because the the original div
blocks, which should remain unaffected, stop sliding across the page

Another thing is happening. Dreamweaver will not allow me to create
new JavaScript variables. I know this because in the Firefox
Javascript console, it gives me the error, "no formal definition" for
any new variables I declare beyond those that are contained in the
moveParas() function contained at the bottom of the page). does anyone
have any idea why that is happening?

I'd really appreicate if someone could help me solve this problem.
forgive me if it is a simple Javascript problem because I am a
Javascript amateur.

<--here is moveParas() -->
function moveParas(switch)
{
alert(switch);
var paraTwo = document.getElementById("paraTwoID");
var paraOne = document.getElementById("paraOneID");
if (paraOneLeft >= 20)
{
paraOne.style.left = 20 + 'px';
stop = true;
}
else
{
paraOneLeft++;
paraOne.style.left = paraOneLeft + 'px';
}
if (stop==true){
if (paraTwoLeft >=100)
{
paraTwo.style.left = 100 + 'px';
}
else
{
paraTwoLeft++;
paraTwo.style.left = paraTwoLeft + 'px';
}
}
}
</SCRIPT>

Mar 1 '06 #1
4 2869
Isn't switch a reserved word in JS!?!

<al*********@gmail.com> wrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
Hi, I'm designing a website in dreamweaver and I'm using JavaScript to
slide text across the page. The text is contained in <div> tags. I
have designed a function which can move two of the div tags across the
screen. I use the timer to manage the movement of the text across the
screen. I would like redesign that function so that it can move any
amount of div blocks across the screen. To do this, I need to pass a
parameter to the function moveParas()

The following set up works fine, calling moveParas which moves two div
code blocks across the screen:

function window_onload()
{
window.setInterval("moveParas()",1);
}

<--moveParas() is located at the bottom of the screen-->
---------------------------------------------------------------------------------------------------------------------------
I have tried to change moveParas() so that it can accept paramaters. I
have tried to pass it variables and hardcoded coded value, but this is
not working. I have of course altered the function itself to accept a
parameter.

function window_onload()
{
var dog = false;
window.setInterval("moveParas(dog)",1);
}

I know the code is causing errors because because the the original div
blocks, which should remain unaffected, stop sliding across the page

Another thing is happening. Dreamweaver will not allow me to create
new JavaScript variables. I know this because in the Firefox
Javascript console, it gives me the error, "no formal definition" for
any new variables I declare beyond those that are contained in the
moveParas() function contained at the bottom of the page). does anyone
have any idea why that is happening?

I'd really appreicate if someone could help me solve this problem.
forgive me if it is a simple Javascript problem because I am a
Javascript amateur.

<--here is moveParas() -->
function moveParas(switch)
{
alert(switch);
var paraTwo = document.getElementById("paraTwoID");
var paraOne = document.getElementById("paraOneID");
if (paraOneLeft >= 20)
{
paraOne.style.left = 20 + 'px';
stop = true;
}
else
{
paraOneLeft++;
paraOne.style.left = paraOneLeft + 'px';
}
if (stop==true){
if (paraTwoLeft >=100)
{
paraTwo.style.left = 100 + 'px';
}
else
{
paraTwoLeft++;
paraTwo.style.left = paraTwoLeft + 'px';
}
}
}
</SCRIPT>

Mar 1 '06 #2
Thanks Adrian,

switch is a reserved word but I changed switch to "blah" and I still
got the same problems

Allan

Mar 1 '06 #3
Hi
below is a complete HTML page that passes text which is then displayed
via your alert that is working...
<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

<title>Untitled Page</title>

<script type="text/javascript" language="javascript">
function moveParas(testit)

{

alert(testit);

var paraTwo = document.getElementById("paraTwoID");

var paraOne = document.getElementById("paraOneID");

if (paraOneLeft >= 20)

{

paraOne.style.left = 20 + 'px';

stop = true;

}

else

{

paraOneLeft++;

paraOne.style.left = paraOneLeft + 'px';

}

if (stop==true){

if (paraTwoLeft >=100)

{

paraTwo.style.left = 100 + 'px';

}

else

{

paraTwoLeft++;

paraTwo.style.left = paraTwoLeft + 'px';

}

}

}

</SCRIPT>

</head>

<body onload="moveParas('test');">

</body>

</html>

<al*********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Thanks Adrian,

switch is a reserved word but I changed switch to "blah" and I still
got the same problems

Allan

Mar 1 '06 #4
Hi Adrian,

Thanks for the help. the only problem was that I was missing a
semicolon after the second onload function call

Thanks Again

Mar 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: andreas | last post by:
Hi there, I have the following situation: 1. DOT.NET Application is started 2. DOT.NET Application instantiates Access.Application.8 3. Opens a specified database (MDB) 4. DOT.NET...
10
by: Resant | last post by:
I have a query : Exec 'Select * From Receiving Where Code In (' + @pCode + ')' @pCode will contain more than one string parameter, eg : A1, A2, A3 How can i write that parameters, I try use :...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
6
by: Catherine Jones | last post by:
Hi all, we need urgent help in a matter. We are trying to pass a COM object from the client to server and are facing some problems in the same. We've our client in C# as well as the Server...
1
by: Maria | last post by:
Hello! I am new to Crystal reports an I have problems passing parameters form outside to Crystal report an creating a report with data from more than one table This is the problem: I have to...
0
by: stephan | last post by:
I know that this has been beaten to death but I can't seem to resolve my issues (I have 2 of them). I have created a class that exposes a public method which returns a datatable as a datasource...
3
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes...
16
by: jimjim | last post by:
#include <stdio.h> #include <stdlib.h> //WARNING: The function's signature should be: f( int ** ) void f(int *ip) { static int dummy = 5; *ip = &dummy; } int main(){
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
6
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper for a C++ DLL file, but am having problems with passing strings as parameters. How should I be writing my C# function call when the C header file is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.