to display/un-hide. I've used this code on one of my other scripts and it works just fine, but I'm not sure why it doesn't work here. Here is a basic version of the code. When I select something from the drop-down menu, nothing happens at all.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Well, you'll be happy to know that you were on the right track. However, firstly, you have to collapse all of the code together (which I was nice enough to do for you).
[syntax="javascript"]<script language="javascript" type="text/javascript">
function WhichForm(frm)
{
if(!frm.eval_form.selectedIndex == 1)
frm.eval_form.focus();
if(frm.eval_form.selectedIndex == 1)
document.getElementById("load").style.display = '';
else
document.getElementById("load").style.display = 'none';
if(frm.eval_form.selectedIndex == 2)
document.getElementById("belt").style.display = '';
else
document.getElementById("belt").style.display = 'none';
if(frm.eval_form.selectedIndex == 3)
document.getElementById("ic").style.display = '';
else
document.getElementById("ic").style.display = 'none';
}
</script>
Next, the error your coming across is simple. You are passing "this.form" into WhichForm(frm), but at no point do you create a form. Just add <form>...</form> around your dropdown box.
Also, the code is really messy. Your tags don't match up in your tables. Just... Here. I needed a break from my current project, so I wasted time and fixed that for you.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Works excellent! I wasn't sure too much about the Javascript part as I happened to find that code online somewhere and just kind of went with it. I didn't know if it could be all together in that one function or not.
The coding was a little weird because I removed 75% of the real stuff so it'd be easier to read so like you said, it was messy. Anyway, it works perfect. Thank you!
You're welcome. By the way, when it comes to having javascript problems, either output anything that you think isn't working to the screen, or use Firebug