[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.6

How to change image onClick when rollover image is active?

Asked by GuanoFun in JavaScript

Tags: change, image, onclick

Hello,
I want to create a rating option for my page, but run into a small problem. My script so far looks like this:

*******************
<html>
<head>
<title>Rating</title>

<script type="text/JavaScript">

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

</script>

<body>

<form>

<img src="starEmpty_5.jpg" width="65" height="13" border="0" name="starsF" id="starsF" usemap="#Stars">

<map name="Stars" id="Stars">
  <area shape="rect" coords="1,1,13,13" href="#1" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('starsF','','starFull_1.jpg',1)">
  <area shape="rect" coords="14,1,26,13" href="#2" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('starsF','','starFull_2.jpg',1)">
  <area shape="rect" coords="27,1,39,13" href="#3" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('starsF','','starFull_3.jpg',1)">
  <area shape="rect" coords="40,1,52,13" href="#4" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('starsF','','starFull_4.jpg',1)">
  <area shape="rect" coords="53,1,65,13" href="#5" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('starsF','','starFull_5.jpg',1)">
</map>

<input type="hidden" name="starRate" value="0">

<input type="submit" name="check" value="Rate it!">

</form>

</body>
</html>
*******************
Here is a link to rar with the images too, if needed: http://www.latgolf.eu/soft/rating.rar
*******************

As you can see, I have created a multu rollover image, that shows me the stars, that i want to click. Now I need a onClick option, then does two things:
1. It changes the orignial image (the gray stars) to a new image, width the stars i fave selected (ie, if i clicked 4 stars, then the original image should change from starEmpty_5.jpg to starFull_4.jpg.
2. Since, voting, i need to know, what i have selected, i need to change the hidden input field "starRate" value (forgot to put that in the archive :-( ) to a new number, that shows me the stars, i gave.

Any suggestions how to correctly do this?
 
Related Solutions
Keywords: How to change image onClick when rol…
 
Loading Advertisement...
 
[+][-]11/02/07 03:42 AM, ID: 20199285Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: JavaScript
Tags: change, image, onclick
Sign Up Now!
Solution Provided By: mplungjan
Participating Experts: 2
Solution Grade: A
 
[+][-]11/02/07 03:56 AM, ID: 20199366Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_2_20070628