Forums

DoubleCombo/Double Dropdown script

edog5948 21 Aug, 2010
Hi -
I'd like to implement a form like this doublecombo (http://www.javascriptkit.com/script/cut183.shtml).

But, I don't know how to handle:
1) the reference to the form name:
inside html:
<form name="doublecombo">

inside javascript:
var groups=document.doublecombo.example.options.length


2) the part of the script that is 'initialization' - that is not inside a function:

<script>
<!--

/*
Double Combo Script Credit
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScripts here!
*/

var groups=document.doublecombo.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()

group[0][0]=new Option("JavaScript Kit","http://javascriptkit.com")
group[0][1]=new Option("News.com","http://www.news.com")
group[0][2]=new Option("Wired News","http://www.wired.com")

group[1][0]=new Option("CNN","http://www.cnn.com")
group[1][1]=new Option("ABC News","http://www.abcnews.com")

group[2][0]=new Option("Hotbot","http://www.hotbot.com")
group[2][1]=new Option("Infoseek","http://www.infoseek.com")
group[2][2]=new Option("Excite","http://www.excite.com")
group[2][3]=new Option("Lycos","http://www.lycos.com")

var temp=document.doublecombo.stage2

function redirect(x){
........


Any assistance on how to get this implemented would be most helpful.
GreyHead 28 Aug, 2010
Hi edog5948,

ChronoForms changes the name of the form, if the form is called 'my_form' in the Forms Manager then it will be called 'ChronoContact_my_form' as far as JavaScript is concerned.

Assuming that MooTools in loaded you can add an id='example' attribute to the select box and use for example $('example').options.count

You can add the script - without the script tags - into the Form JavaScript box on the Form Code tab.

Bob

PS There's a slightly simpler way of doing this using Option Groups described on page 187 of the ChronoForms book.
This topic is locked and no more replies can be posted.