Jump to content

need help on image change


pixeltrace

Recommended Posts

hi,

 

i am not very good on javascript yet, and i usually just use free javascript online.

 

currenty i have a javascript code

<HTML>
<HEAD>
<script type="text/javascript">

function ShowItem()
{

var Index = document.getElementById("Country").selectedIndex;
var country = document.getElementById("Country").options[index].value;

switch(country)
{
	case "SG":
		document.getElementById("MC").innerHTML = "SGD 3,249";
		break;
	case "ML":
		document.getElementById("MC").innerHTML = "RM 7,389";
		break;
	case "PH":
		document.getElementById("MC").innerHTML = "PHP 102,499";
		break;
	case "TL":
		document.getElementById("MC").innerHTML = "BHT 69,459";
		break;
	case "IN":
		document.getElementById("MC").innerHTML = "USD 2,109";
		break;
}

}

function Load() {
document.getElementById("Country").selectedIndex=0;
		document.getElementById("MC").innerHTML = "SGD 3,249";
}
</script>


</HEAD>
<BODY onload="Load()">
	<select id="Country" onchange="ShowItem()" width="150">
		<option selected value="SG">Singapore</option>
		<option value="ML">Malaysia</option>
		<option value="PH">Philippines</option>	
		<option value="TL">Thailand</option>
		<option value="IN">Indonesia</option>
	</select>

<span id="MC"></span>

</BODY>
</HTML>

 

 

 

and this is meant for menu list wherein if you select one item on the menu list

it will change the value in the <span> section.

 

i will be needing this code and use it for image button instead of the menu list

wherein if on mouseover, the item on the <span> will change. on the <span>

section i am planning to use image instead of text.

 

hope you could help me modify the codes.

 

thanks!

Link to comment
Share on other sites

You don't really need to modify a javascript to understand that you just need a basic understanding of javascript DOM

here is an example

//function that changes the value in <span id="myspan"></span>
function changeSpan(newValue)
{
document.getElementById('mySpan').innerHTML=newValue;
}
</script>
</head>

<body>
<!--when you click on a link the value is passed to the javascript function "change span"-->
<a href="javascript:changeSpan('first action')">1</a>
<a href="javascript:changeSpan('second action')">2</a>
<a href="javascript:changeSpan('third action')">3</a>
<br />
<span id="mySpan"></span>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.