PDA

View Full Version : Integrating JQuery and Javascript in the same function?



Caution
25 Mar 2011, 12:07 PM
Hello,

I'm attempting to create a system that will allow, when you hover over something, to change information in one area, and then use the fade functions of JQuery at the same time. The function affected is here:



function WhatsNewCaption(linkNumber, parameter) {
if(parameter>0) {
document.getElementById("WhatsNewCaption").innerHTML=document.getElementById("JavaScriptWhatsNewPicture"+linkNumber).alt;
var genericCounter=1;
while(genericCounter) {
if(document.getElementById("JavaScriptWhatsNewPicture"+genericCounter)) {
$("#JavaScriptWhatsNewPicture"+genericCounter).fadeOut(1,0.3);
genericCounter++;}
else {
break; } }
$("JavaScriptWhatsNewPicture"+linkNumber).fadeIn(50,1.0); }
else {
document.getElementById("WhatsNewCaption").innerHTML=""; } }


The issue is when this function is called, it simply does nothing. This type of integration has worked once before and I didn't change the syntax, but I question if it really should have ever worked before then... anyways, help?

Caution
25 Mar 2011, 04:13 PM
Update to this situation:

Did some more research, modified the code to:



function WhatsNewCaption(linkNumber, parameter) {
if(parameter>0) {
document.getElementById("WhatsNewCaption").innerHTML=document.getElementById("JavaScriptWhatsNewPicture"+linkNumber).alt;
var genericCounter=1;
while(genericCounter) {
if(document.getElementById("JavaScriptWhatsNewPicture"+genericCounter)) {
$("#JavaScriptWhatsNewPicture"+genericCounter).fadeTo(700,0.3);
genericCounter++;}
else {
break; } }
$("JavaScriptWhatsNewPicture"+linkNumber).fadeTo(700,1.0); }
else {
document.getElementById("WhatsNewCaption").innerHTML="";
$("JavaScriptWhatsNewPicture2").fadeTo(700,1.0); } }


Now, the picture being chosen when parameter =1 (mouseover) will cause all the pictures to fade out (correct), but the one hovering will not become clear. Likewise, when parameter is 0 (mouseout), all the pictures stay faded, but the 2nd picture should always become more clear in this situation. Unsure what to do here - help?