By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,947 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,947 IT Pros & Developers. It's quick & easy.

linked dropdownboxes, php

P: n/a
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


Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ward <ki************@for.president.com> wrote in
news:Xn**********************************@195.130. 132.70:
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
Jul 20 '05 #2

P: 7
Here's a modular, customizable script for linked select boxes, from WebOnWebOff.com.

You can specify what options to display at the start, or options to display when no options exist for the selected value.

http://www.webonweboff.com/widgets/j...selection.aspx

Hope this helps...
Jun 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.