Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop down menu to change picture

Status
Not open for further replies.

Nexusens

Programmer
Feb 6, 2007
22
CA
I am trying to upgrade my site to xhtml 1.1. I modified this code and it wouldn't work. so I dropped it back into 1.0 transitional and it still didn't work. can anyone see what wrong. and how do i make it 1.1 friendly. You can view the full source at
<html>
<body>
<div id="main">
<script type="Javascript">
kokaneeblade = new Array();
kokaneeblade[1] = "Graphics/Trolls/Blade N.png";
function kblade(optionid){document.getElementById("kb").src = kokaneeblade[optionid];}
</script>
<p class="style1">
<img alt="" class="style6" src="Graphics/Trolls/Blade N.png" id="kb" />
<select id="kb" class="style3" name="Kokane Blade" onchange="javascript: kblade(this.value);">
<option style="color:green" selected="selected">Blade</option> <option style="color:green" value="1">Nickel (N)</option> </select>
</p>
</div>
</body>
</html>
 
The link does not work. What is the validator complaining about? Here's a few things I would do:

1. change script type to "text/javascript"
2. add comments at the beginning of javascript code hide it from html.
3. use a form element if I am using form controls.
4. add head section to the page, especially the title tag within the head.
 
One thing I will add to Vragabond, though he pretty much nailed it, I would also make sure your <script> tag is in the <head> section.

If the script doesn't HAVE to be anywhere besides the within the <head> section, make sure that it is in the <head> section.

<.

 
Thank you Vragabond. The text/javascript was the problem, cant't belive I missed that. I do have a head section I just enteret the html body div tags as they were to show the relative position of the code.


"Tsune ni ite, kyu ni awasu
 
also monksnake sugested to put the script in the head section what is the reason for this as I have a very large number of file to do this to and dont want to with out a good reason

"Tsune ni ite, kyu ni awasu
 
It's not necessary, but it makes your code cleaner, and it ensures that the script is loaded before your page is.

<.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top