SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't get dropdown to work. Bug? Help ASAP!!!!

    Ok... so I'm designing a new high school website and have it almost done. Here's the progress: http://70.103.16.165/~esmsator/

    I'm trying to add a dropdown menu on the rightmost column under the calendar that will have a list of teachers and automatically redirect to each of their individual pages.

    I added this code in the head
    Code:
    <script language="javascript">
    <!--
    function go() {
    	box = document.forms[0].url;
    	destination = box.options[box.selectedIndex].value;
    	if (destination) location.href = destination;
    }
    //-->
    </script>
    And this in the 3rd column
    Code:
    	<form method="post" action="/">
    		<fieldset style="border:none;">
    
    		<label id="stafflist"><select name="url" onchange="go();">
    			<option value="">---</option>
    			<option value="http://msat1.es-msat.org/~calmasy">Almasy, Corey</option>
    			<option value="http://msat1.es-msat.org/~tbanks">Banks, Tiffani</option>
    			<option value="http://msat1.es-msat.org/~aharris">Cala, Lexie</option>
    			<option value="http://msat1.es-msat.org/~tcurran">Curran, Ted</option>
    			<option value="http://msat1.es-msat.org/~amiller">Dossat, Alyssa</option>
    			<option value="http://msat1.es-msat.org/~aharris">Harris, Tony</option>
    			<option value="http://msat1.es-msat.org/~jhorowitz">Horowitz, Josh</option>
    			<option value="http://msat1.es-msat.org/~dhyatt">Hyatt, Donna</option>
    			<option value="http://msat1.es-msat.org/~skinney">Kinney, Steve</option>
    			<option value="http://msat1.es-msat.org/~mfung">Lee, Melissa</option>
    			<option value="http://msat1.es-msat.org/~jmurphy">Murphy, Jason</option>
    			<option value="http://msat1.es-msat.org/~mnoyes">Noyes, Meredith</option>
    			<option value="http://msat1.es-msat.org/~hcharles">Wells, Heather</option>
    			<option value="http://msat1.es-msat.org/~jwells">Wells, Justin</option>
    		</select></label>
    		</fieldset>
    	</form>
    It worked when I mocked up a stripped-down version of the site, but not when it's incorporated into the whole page.

    I finally found out that for some reason, it only works when every other form tag is removed from the page. Why is this happening and how can I fix it? I need this fixed ASAP. Thanks.
    Bjerke Web Design
    http://bjerkewebdesign.com

  2. #2
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form name

    This is my first response, so excuse any mistakes. I think the issue is the document.forms[0].url. If you only have one form, this statement will work fine, but if you have more than one form in your web page, your code is referencing the wrong form. You can add a name to your form like:

    <form name="teacher" method="post" action="/">

    and then change the script to reference the specific form:

    <script language="javascript">
    <!--
    function go() {
    box = document.teacher.url;
    destination = box.options[box.selectedIndex].value;
    if (destination) location.href = destination;
    }
    //-->
    </script>

    I think that will work.

    Good luck,
    --Dennis


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •