linked dropdownboxes, php

W

Ward

Hi,

Consider a window with 2 linked dropdownboxes, dynamically
fed from a dbase.

One technique to implement this would be to use an onchange
event on the first box, then have the script call itself again,
this time with a GET variable, calling the db for a 2nd time to
populate the 2nd dropdownbox. (using PHP)

That's fine when you have a local connection to a db, as you have
little connection-setup-costs, and only minor image flicker.


I'm not, so I'm trying to do this :

My PHPscript calls the db ONCE, then it writes the <options> for
the second dropdownbox in a javascript function 'showlinks'.
The opt function does the actual document.writing
<head>
...
function showlinks() {
if (hoofdregio =='ASSE') {
opt('xxx','Allemaal');
opt('yyy','ASSE');
opt('zzz','BRU');}

if (hoofdregio =='BKH') {
opt('xxx','Allemaal');
...
}

</head>


My problem is that for this to work, creating the 2nd dropdownbox
has to be done in javascript completely like so :


document.write('<FORM NAME="subregios"' + 'onSubmit="return load
(document.subregios.subregio)">');
document.write('<SELECT NAME="subregio">');
document.write('<OPTION SELECTED>Allemaal<\/option>');
showlinks();
document.write('<\/SELECT>');
document.write('<INPUT TYPE="SUBMIT" VALUE="Go">');
document.write('<\/FORM>');


What I would like to do is this :

<select name="subregio">
<option selected>allemaal</option>
<script>showlinks();</script>
</select>



Any ideas ?


thx

Ward
 
W

Ward

Hi,

Consider a window with 2 linked dropdownboxes, dynamically
fed from a dbase.

One technique to implement this would be to use an onchange
event on the first box, then have the script call itself again,
this time with a GET variable, calling the db for a 2nd time to
populate the 2nd dropdownbox. (using PHP)

That's fine when you have a local connection to a db, as you have
little connection-setup-costs, and only minor image flicker.


I'm not, so I'm trying to do this :

My PHPscript calls the db ONCE, then it writes the <options> for
the second dropdownbox in a javascript function 'showlinks'.
The opt function does the actual document.writing
<head>
..
function showlinks() {
if (hoofdregio =='ASSE') {
opt('xxx','Allemaal');
opt('yyy','ASSE');
opt('zzz','BRU');}

if (hoofdregio =='BKH') {
opt('xxx','Allemaal');
..
}

</head>


My problem is that for this to work, creating the 2nd dropdownbox
has to be done in javascript completely like so :


document.write('<FORM NAME="subregios"' + 'onSubmit="return load
(document.subregios.subregio)">');
document.write('<SELECT NAME="subregio">');
document.write('<OPTION SELECTED>Allemaal<\/option>');
showlinks();
document.write('<\/SELECT>');
document.write('<INPUT TYPE="SUBMIT" VALUE="Go">');
document.write('<\/FORM>');


What I would like to do is this :

<select name="subregio">
<option selected>allemaal</option>
<script>showlinks();</script>
</select>



Any ideas ?


thx

Ward

Forget it, problem solved.

Ward
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,093
Messages
2,570,607
Members
47,227
Latest member
bluerose1

Latest Threads

Top