Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Change picture onclick...How can it stay changed?
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
asteffes




PostPosted: Tue May 30, 2006 1:53 pm   Post subject: Change picture onclick...How can it stay changed?

Hey all,

I'm programming a website with css/html in Visual Studio 2005. I would like to have my hyperlink image CHANGE its image when it is selected, and stay that way when the new page loads up. Alternately, when the page is not selected, I would like its image to return to its natural state.


I've managed to use a small javascript to change image with "onmouseover" and "onmouseout" very easily, yet I cannot get these images to stay changed.

Any suggestions would be greatly appreciated, thank you!
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue May 30, 2006 2:21 pm   Post subject: (No subject)

you'd need to start a session with user to keep track of state changes
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
asteffes




PostPosted: Tue May 30, 2006 3:59 pm   Post subject: (No subject)

Ok thanks.

Any suggestions on where to learn about setting up a session with state-tracking?
Tony




PostPosted: Tue May 30, 2006 4:10 pm   Post subject: (No subject)

well if you're using JavaScript only, then you are limited to playing with cookies yourself.

otherwise you can use script languages such as Ruby and PHP to create sessions with server-side. It depends on your language preferences.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
asteffes




PostPosted: Tue May 30, 2006 4:31 pm   Post subject: (No subject)

Unfortunately my Java skills are limited, and I don't have any knowledge of Ruby or PHP.

I'm developing the site in Visual Studio 2005, which is not very java friendly to begin with.

I will search around the internet for some tutorials on this. I think that it might be more trouble than its worth right now for me to go through all of that.

Perhaps I will just make individual webpages with the image static on their respective pages. That will make switching back and forth between images very simple. However, I still have a problem with the front page that requires a more detailed description. That's unnecessary for now, however.

Thanks for your help, its greatly appreciated as a new web developer.

EDIT** Fixed the problem below by changing the img_id to img_name and taking the client side code out of the form.

I've got one question I'll throw out there to see if there is any aid available. Ive been running into this error with my javascript designed to switch over the image on an onmouseover event:

"img_name" is not defined

here is my code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="kdx.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<script language="javascript" type="text/javascript">

function movepic(img_id,img_src)
{
document.getElementById(img_name).src = img_src
}

</script>
Tony




PostPosted: Tue May 30, 2006 4:58 pm   Post subject: (No subject)

you are trying to access a variable called img_name that has not been defined, it's that simple Razz

code:

 function movepic(img_id,img_src)
{
document.getElementById(img_id).src = img_src
}

if you are getting Elements by ID, then I'm going to guess that you want to use img_id (which is an argument for your function).

asteffes wrote:

Unfortunately my Java skills are limited

I have not mentioned Java.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: