Reply to Re: dynamic drop down menu (part 2)...

Your name:

Reply:


Posted by Jonathan N. Little on 12/11/18 11:40

firstcustomer@gmail.com wrote:
> Further to my earlier post, I've found something that does partly what
> I'm doing, but there are two issues:


The reason you did not get a satifactory response is that most feel that
what your are attempting is a 'bad idea'. But in the matter of
JavaScript (which must be enabled for the form to work, the other bad
idea) you have some obvious errors which I will show to you, educational
and all.
>
> 1) There is an error in the script. Being a Javascript newbie, I've no
> idea what the problem is.
>
> 2) I don't know how to re-program the script so that it opens up a url
> depending on the choices made.
>
> Here is the code (thanks Google!), I'd appreciate any help the you can
> give.
>
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

Ugh, please look up doctype. This is ancient.
> <HTML>
> <HEAD>
> <TITLE>Dynamic Dropdown Boxes</TITLE>
> <META NAME="Generator" CONTENT="TextPad 3.0">
> <META NAME="Author" CONTENT="Heidi Housten">
> </HEAD>
>
>
> <style>
> body,table,td {font-family:verdana; font-size:9pt}
> select {width:130;font-family:verdana}
> pre { font-size:9pt }
> </style>
>
>
>
>

Next although ending JavaScript statements with a ';' is optional I
recommend it because is prevents errors when a single statement spans
more than on line. Also your can gang more than one statement on a
single line:
var aOpt=new Array; var oMine=new Object;

>
> <script language=javascript>
> <!--
> mainOpt = new Array()
> subOpt = new Array()
> mainOpt[0] = "How to relax"
> subOpt [0] = new Array("","","")
> mainOpt[1] = "Hot Spots"
> subOpt [1] = new Array("Pick a Hot Spot","Mojave","Mars","Death
> Valley","Mt. St. Helens")
> mainOpt[2] = "Festivals"
> subOpt [2] = new Array("Which One?","Mardi Gras","Cinco de
> Mayo","Midsummer","Kite Festival")
> mainOpt[3] = "Good Books"
> subOpt [3] = new Array("Which Book?","N is for Noose","Four to
> Score","A Grave Talent","Six of One")
> mainOpt[4] = "Holidays"
> subOpt [4] = new Array("Choose
> Holiday","Cruises","Safaris","Ballooning","Adventures")
> function init()
> {
>
> fillCombo(document.forms.myMenus.mainMenu,mainOpt)
> fillCombo(document.forms.myMenus.mainBox,mainOpt)
Incorrect here-------------------------^^------^^^
should be:

fillCombo(document.forms.myMenus.subMenu,subOpt[0]);

to fill the second SELECT "subMenu" with the 1st array "subOpt[0]" upon
initialization.


> }
>
> function fillCombo(cmbBox,aryMenu)
> {
> cmbBox.length = 0 // Clear out the current options
> for (menuOpt in aryMenu)
> {
> cmbBox.options[cmbBox.length] = new
> Option(aryMenu[menuOpt],cmbBox.length)
> }
> //Show first item if it is a drop down
> cmbBox.selectedIndex=0
> }
> //-->
> </script>
>
> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" onload="init()">
> <center>
> <form name=myMenus>
> <br>an example<br><br>
> <!-- do select template for older browsers, some
> can't change size dynamically -->
> <select name=mainMenu
> onchange="fillCombo(subMenu,subOpt[this.selectedIndex])">
-------------------------^^^
should pass the complete reference to the SELECT object:

onchange="fillCombo(this.form.subMenu, subOpt[this.selectedIndex]);



> <option>
> <option>
> <option>
> <option>
> <option>
> <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> </select><br><br>
> <select name=subMenu>
> <option>
> <option>
> <option>
> <option>
> <option>
> <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> </select>
> <br>
> </form>
> </center>
> </BODY>
> </HTML>
>

Probably more but that is what I found on quick examination.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация