pixeltrace Posted June 22, 2007 Share Posted June 22, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/56692-need-help-on-image-change/ Share on other sites More sharing options...
RichardRotterdam Posted June 27, 2007 Share Posted June 27, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/56692-need-help-on-image-change/#findComment-284083 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.