Geeting ImageUrl when changed by javascript

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>
 
E

Eric Lawrence [MSFT]

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.
 
J

Joe

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>
 
E

Eric Lawrence [MSFT]

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top