View Full Version : need help loading a function

10-06-2003, 02:26 PM

I have a function which populates a drop down list, based on the selection of another list. I have an "onChange" function for the second drop down which refreshes the screen, then queries my DB based on the selections made..

its prolly best for you to see an example...


now, you first select the module drop down, which in turn will populate the process drop down. when you select a process, it will refresh the page, and as you can see across the URL is the selections you made. I use PHP to then determin what has been selected and try to get the drop downs to match that.

Once you've selected a process and the page has refreshed, if you press the "CLICK ME" button it will populate the process drop down with your current selection.

my problem is that I cannot call this function any other way, other than using the onclick button. I need it to be abe to be called when the page loads.

I've tried the onload body event, I've tried simpy calling the script, both do not work.
any suggestions?

thanks.... :p

10-06-2003, 09:22 PM
<form name="doublecombo">
<p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option>Technology Sites</option>
<option>News Sites</option>
<option>Search Engines</option>
<select name="stage2" size="1">
<option value="http://www.cnet.com">CNET</option>
<option value="http://www.news.com">News.com</option>
<option value="http://www.wired.com">Wired News</option>
<input type="button" name="test" value="Go!"


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("Website Abstraction","http://www.cnet.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){
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(){


10-07-2003, 09:28 AM
thanks for the reply, but I need the page to be reloaded with the options selected in the dropdowns..... :)