View Full Version : Alert Box and Menu Help!!! AGH!

06-03-2004, 09:41 AM
Okay..i have the drop down menu...and I'm trying to make it so when you select "choose a genre" or "-------" an alert box pops up saying "please choose"...I'm 99.99% sure that my error is in the javascript part of the html...thnx for helping a beginner!

This is what I have:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<title>Tom's Music Page</title>
<link rel="stylesheet" type="text/css" href="intro.css" />

<script language="Javascript">

function go()

if ( location=document.drop.mus.option[document.drop.mus.selectedIndex].asdf return

alert('Choose Again');



<h1>Choose A Genre!</h1>
</ br>
<img src="piano.jpg" width="502" alt="" />
<form name="drop">
<select name="mus" onChange="go()">
<option value="asdf">Choose a Genre!</option>
<option value="asdf">-------------</option>
<option value="page1.html">Hip-Hop</option>
<option value="page2.html">Alternative</option>
<option value="page3.html">Classical</option>
<option value="asdf">-------------</option>
<option value="index.html">Home!</option>



06-03-2004, 10:06 AM
function go(objSelect)
var val = objSelect.options[objSelect.selectedIndex].value;
if (val=='asdf') {
alert('Choose Again');
else {
<select name="mus" onChange="go(this)">

Using the this keyword simplifies the function. It doesn't need to know what the form name and select name are.

06-03-2004, 10:10 AM
OMGOMGOMGOMG You did it!!! THnx!!!!!!! I owe you!!!