...

View Full Version : onMouseOver-SeveralImages-and disable-enable problem



rayesteq
10-27-2004, 02:21 PM
Hi everybody;

I hava a code ==>

<script language="JavaScript">

var prevClicked = "";
Imgpath="../images/styleguide/";

function staySet(curr,imgName){


tmpStr = curr.toString();
if (prevClicked == "")
{
document.getElementById(curr).disabled = true;
prevClicked = curr;
}
else
{
document.getElementById(prevClicked).disabled = false;
document.getElementById(curr).disabled = true;
prevClicked = curr;
}
}


function SwapImage(curr,imgName) {

tmpStr = curr.toString();
var swap = event.type;

if (swap == 'mouseover')
{
document.getElementById(curr).src=Imgpath+imgName+'_prs.gif'
document.getElementById(curr).disable=false;
}

if (swap == 'mouseout')
{
document.getElementById(curr).src=Imgpath+imgName+'_def.gif'
}


}
</script>




Inthis code ="document.getElementById(prevClicked).disabled = false;"
part doesn't work...So my complete code become a ruin? if somebody knows hao can i enable or disable a image button???

Thanks for your consideration


rayesteq

Mr J
10-27-2004, 03:04 PM
You are getting the event type inside a function which will return "click"

var swap = event.type;

therefore your mouseout and mouseover arguments are not valid.

Are you trying to do an image rollover?

rayesteq
10-27-2004, 03:18 PM
onmouseover="SwapImage(imagId,'imgPath')"
onmouseout="SwapImage(imgId,'imgPath')"


onclick="javascript:staySet(imgId,'imgName')"
href="<#apppath>?layoutid=6001&node=<#insert field="node">"

I use something like that to call the function staySet()...Actualy I controlled if it gets into this function with alerts ; yes it goes into this function but the disabled=false or true part doesn't work?

I actualy want to make an image rollover yes; but moreover when the user clicks on an image I want my image preserves its last visiaul stituation until user clicks another one...


Meanwhile Thanks for your quick reply :)

Mr J
10-27-2004, 05:15 PM
Here's a script I have that does what you want, just amend the image info



<script language="JavaScript">
<!--
var Images = new Array("images/pic2_tn.jpg","images/pic1_tn.jpg","images/pic3_tn.jpg") // list images to preload
var preloadImages=new Array() // preloads images
for (i=0;i<=Images.length-1;i++) {
preloadImages[i]=new Image()
preloadImages[i].src=Images[i]
}

LastID = ""

function m_over(id){
(LastID != id?document.getElementById(id).src = "images/pic02_tn.jpg":"")
}

function m_out(id){
(LastID != id?document.getElementById(id).src = "images/pic01_tn.jpg":"")
}

function m_click(id){
document.getElementById(id).src = "images/pic03_tn.jpg"
if (LastID != ""){
(LastID != id?document.getElementById(LastID).src = "images/pic01_tn.jpg":"")
}
LastID = id
}
// -->
</script>

<a href="#null" onMouseOver="m_over('image1');" onMouseOut="m_out('image1')" onClick="m_click('image1')"><img src="images/pic01_tn.jpg" border="0" id="image1"></a>

<a href="#null" onMouseOver="m_over('image2');" onMouseOut="m_out('image2')" onClick="m_click('image2')"><img src="images/pic01_tn.jpg" border="0" id="image2"></a>

<a href="#null" onMouseOver="m_over('image3');" onMouseOut="m_out('image3')" onClick="m_click('image3')"><img src="images/pic01_tn.jpg" border="0" id="image3"></a>

<a href="#null" onMouseOver="m_over('image4');" onMouseOut="m_out('image4')" onClick="m_click('image4')"><img src="images/pic01_tn.jpg" border="0" id="image4"></a>

<a href="#null" onMouseOver="m_over('image5');" onMouseOut="m_out('image5')" onClick="m_click('image5')"><img src="images/pic01_tn.jpg" border="0" id="image5"></a>

<a href="#null" onMouseOver="m_over('image6');" onMouseOut="m_out('image6')" onClick="m_click('image6')"><img src="images/pic01_tn.jpg" border="0" id="image6"></a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum