View Full Version : Combo Box and Text Search

04-29-2004, 06:39 PM
I don't have much experience using javascript, other than cutting and pasting so I need a little help with the search capability I'm trying to implement on a set of static HTML pages (yeah, static - gotta do what the customer wants, uuuhhh!).

Anyway, I'm using the Double Combo Script found at JavaScript Kit to populate 2 sets of combo boxes -- code below

<form name="doublecombo">

<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option>Army Courseware</option>
<option>Air Force Courseware</option>
<option>Marine Courseware</option>
<option>Navy Courseware</option>
<option>Joint Courseware</option>

<select name="stage2" size="1">
<option>MOS Related</option>
<option>NCO Education System</option>
<option>Officer Education System</option>
<option>Professional Development</option>
<option>Self Development</option>

<!-- <input type="button" name="test" value="Go!"
onClick="go()"> -->



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("MOS Related")
group[0][1]=new Option("NCO Education System")
group[0][2]=new Option("Officer Education System")
group[0][3]=new Option("Professional Development")
group[0][4]=new Option("Self Development")

group[1][0]=new Option("AFSC Related")
group[1][1]=new Option("Ancillary Related")
group[1][2]=new Option("Professional Military Education")
group[1][3]=new Option("Professional Development")
group[1][4]=new Option("Self Development")
group[1][5]=new Option("Specialized Courses")

group[2][0]=new Option("MOS Related")
group[2][1]=new Option("Professional Development")
group[2][2]=new Option("Self Development")

group[3][0]=new Option("Courseware Categories")
group[3][1]=new Option("Video Teletraining Program")

group[4][0]=new Option("Joint Course Listing")

var temp=document.doublecombo.stage2

function redirect(x){
for (m=temp.options.length-1;m>0;m--)
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)

function go(){


I have commented out the Go button and the links because I don't want to jump to a url from the combo box selection.

I'm using a text field below the combo box selection to employ a search feature on the static pages -- code below:


<form name="JF1" action="javascript:FND(document.JF1.JT1.value)">
<input type="text" name="JT1" size=20>
<input name="submit" type="submit" value="Search">

This basically submits to a .js file that has indexed all directories. I am going to index each directory on the site so each directory has its own .js file.

So, what I need to happen is based on the second combo box selection and the search text string I need the submit form to say something like:

Option = "MOS Related" then action="javascript:FND(document.JF1.JT1.value")

else if

Option = "NCO Education System" then
action = "javascript:FND(document.JF1.JT1.value")

else if


Anyone have some ideas for me - thank for helping out a js newbie in advance!