steverguy
asked on
Javascript Functions
I'm trying to execute a javascript function that requires a set number of values. The values need to be pulled from a database using asp.
The function I'm using is basically a photo gallery. It changes the image as well as various text fields located around the image using element ids. I have 2 buttons on my site that I want to use to cycle through the images.
The link for the buttons are:
<a href="#_self" onclick="MoveNext(0,x)"> and <a href="#_self" onclick="MoveNext(1,x)">
x is suppose to be the number of the current picture
Here's the javascript code I have:
<script language="Javascript">
function MoveNext(Direct,curPic)
{
if (Direct == 0){
x = curPic - 1
}
if (Direct == 0){
x = curPic + 1
}
// eventually i want to fill these arrays from a database
pictureA = new Array("build.jpg","buy.jpg ","rent.jp g")
highschoolA = new Array("Kent Co.","Grand Traverse","Kalkaska")
yearbuiltA = new Array("1999","2000","2006" )
archiA = new Array("Ranch","Duplex","Tw o Story")
sqfeetA = new Array("1000","2000","3000" )
priceA = new Array("250,000","120,000", "75,000")
bathA = new Array("2","3","4")
bedA = new Array("1","7","5")
thelinkA = new Array("images/icons/build. jpg","imag es/icons/b uy.jpg","i mages/icon s/rent.jpg ")
function Gallery(pictureName,imageF ile,highsc hool,yearb uilt,archi ,sqfeet,pr ice,bath,b ed,thelink )
{
if (document.all)
{
document.getElementById(pi ctureName) .style.fil ter="blend Trans(dura tion=1)";
document.getElementById(pi ctureName) .filters.b lendTrans. Apply();
}
document.getElementById(pi ctureName) .src = imageFile;
if (document.all)
{
document.getElementById(pi ctureName) .filters.b lendTrans. Play();
}
document.getElementById("s chool").in nerHTML=hi ghschool;
document.getElementById("y earbuilt") .innerHTML =yearbuilt ;
document.getElementById("a rchi").inn erHTML=arc hi;
document.getElementById("s qfeet").in nerHTML=sq feet;
document.getElementById("p rice").inn erHTML=pri ce;
document.getElementById("b ed").inner HTML=bed;
document.getElementById("b ath").inne rHTML=bath ;
document.getElementById("t helink").i nnerHTML=t helink;
}
Gallery('pictureName',imag eFileA(x), highschool A(x),yearb uiltA(x),a rchiA(x),s qfeetA(x), priceA(x), bathA(x),b edA(x),the linkA(x))
Return(x);
}
</script>
I'm new to javascript, so I wrote the MoveNext function the way it made sense to me - which is obviosuly wrong. No laughing please :) - the Gallery function was written by someone else, and it works fine by itsself.
If anyone can point me in the right direction here, I'd appreciate it!
The function I'm using is basically a photo gallery. It changes the image as well as various text fields located around the image using element ids. I have 2 buttons on my site that I want to use to cycle through the images.
The link for the buttons are:
<a href="#_self" onclick="MoveNext(0,x)"> and <a href="#_self" onclick="MoveNext(1,x)">
x is suppose to be the number of the current picture
Here's the javascript code I have:
<script language="Javascript">
function MoveNext(Direct,curPic)
{
if (Direct == 0){
x = curPic - 1
}
if (Direct == 0){
x = curPic + 1
}
// eventually i want to fill these arrays from a database
pictureA = new Array("build.jpg","buy.jpg
highschoolA = new Array("Kent Co.","Grand Traverse","Kalkaska")
yearbuiltA = new Array("1999","2000","2006"
archiA = new Array("Ranch","Duplex","Tw
sqfeetA = new Array("1000","2000","3000"
priceA = new Array("250,000","120,000",
bathA = new Array("2","3","4")
bedA = new Array("1","7","5")
thelinkA = new Array("images/icons/build.
function Gallery(pictureName,imageF
{
if (document.all)
{
document.getElementById(pi
document.getElementById(pi
}
document.getElementById(pi
if (document.all)
{
document.getElementById(pi
}
document.getElementById("s
document.getElementById("y
document.getElementById("a
document.getElementById("s
document.getElementById("p
document.getElementById("b
document.getElementById("b
document.getElementById("t
}
Gallery('pictureName',imag
Return(x);
}
</script>
I'm new to javascript, so I wrote the MoveNext function the way it made sense to me - which is obviosuly wrong. No laughing please :) - the Gallery function was written by someone else, and it works fine by itsself.
If anyone can point me in the right direction here, I'd appreciate it!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help. I'll really have to look it over, as some of it is over my head. But i feel much further now than I did when i ran into the problem yesterday. Thanks for your help!
<script language="JavaScript" type="text/javascript">
<!--
//-=-=-=-=-=-=-=-=-=-=-=-=
function MoveNext(Direct,curPic) {
if (Direct == 0){
x = curPic - 1
}
if (Direct == 0){
x = curPic + 1
}
// eventually i want to fill these arrays from a database
pictureA = new Array("build.jpg","buy.jpg
highschoolA = new Array("Kent Co.","Grand Traverse","Kalkaska")
yearbuiltA = new Array("1999","2000","2006"
archiA = new Array("Ranch","Duplex","Tw
sqfeetA = new Array("1000","2000","3000"
priceA = new Array("250,000","120,000",
bathA = new Array("2","3","4")
bedA = new Array("1","7","5")
thelinkA = new Array("images/icons/build.
Gallery('pictureName',imag
Return(x);
}
//-=-=-=-=-=-=-=-=-=-=-=-=
function Gallery(pictureName,imageF
if (document.all)
{
document.getElementById(pi
document.getElementById(pi
}
document.getElementById(pi
if (document.all)
{
document.getElementById(pi
}
document.getElementById("s
document.getElementById("y
document.getElementById("a
document.getElementById("s
document.getElementById("p
document.getElementById("b
document.getElementById("b
document.getElementById("t
}
}
//-->
</script>
Preece