Geeting ImageUrl when changed by javascript

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

I have a function that changes an image when the user clicks a button (this
works fine). There's another button that is used to transfer to another page
an pass the selected image as a querystring. The problem is in the code
behind, Image1.ImageUrl always returns the initial image name. Is there a
way to get the newly selected one?

<script language="javascript">
<!--
var Images = new Array();

Images[0] = "Image1.jpg";
Images[1] = "Image2.jpg";
Images[2] = "Image3.jpg";

var Index = 0;

function ChangeImage(forward)
{
if (forward == true)
{
if (Index >= Images.length - 1)
Index = 0;
else
Index++;

document.frmFriend.Image1.src = Images[Index];
}
else
{
if (Index == 0)
Index = Images.length - 1;
else
Index--;

document.frmFriend.Image1.src = Images[Index];
}
}
//-->
</script>
 
A really simple way would be to have your change image function also update
the value of an <Input type=hidden> tag.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
can you explain more? possible some code?

Thanks,
Joe

Eric Lawrence said:
A really simple way would be to have your change image function also update
the value of an <Input type=hidden> tag.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.


Joe said:
I have a function that changes an image when the user clicks a button (this
works fine). There's another button that is used to transfer to another page
an pass the selected image as a querystring. The problem is in the code
behind, Image1.ImageUrl always returns the initial image name. Is there a
way to get the newly selected one?

<script language="javascript">
<!--
var Images = new Array();

Images[0] = "Image1.jpg";
Images[1] = "Image2.jpg";
Images[2] = "Image3.jpg";

var Index = 0;

function ChangeImage(forward)
{
if (forward == true)
{
if (Index >= Images.length - 1)
Index = 0;
else
Index++;

document.frmFriend.Image1.src = Images[Index];
}
else
{
if (Index == 0)
Index = Images.length - 1;
else
Index--;

document.frmFriend.Image1.src = Images[Index];
}
}
//-->
</script>
 
Provide your code and I'll tweak it.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

Joe said:
can you explain more? possible some code?

Thanks,
Joe

Eric Lawrence said:
A really simple way would be to have your change image function also update
the value of an <Input type=hidden> tag.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.


another
page
there
a
way to get the newly selected one?

<script language="javascript">
<!--
var Images = new Array();

Images[0] = "Image1.jpg";
Images[1] = "Image2.jpg";
Images[2] = "Image3.jpg";

var Index = 0;

function ChangeImage(forward)
{
if (forward == true)
{
if (Index >= Images.length - 1)
Index = 0;
else
Index++;

document.frmFriend.Image1.src = Images[Index];
}
else
{
if (Index == 0)
Index = Images.length - 1;
else
Index--;

document.frmFriend.Image1.src = Images[Index];
}
}
//-->
</script>
 
Back
Top