On Fri, November 4, 2005 11:24 am, Bhoomi Vora wrote:
I have a php page which contains three combo boxes.
The first one will have the value
from the mysql database table on page load itself.
Then depending upon the value selected in the first
combobox the second combo box
should be populated with the respective values from
another mysql database table, and
once again depending upon the value selected in second
combobox the third combobox
should be populated with the respective values from
one more different database table.
I have read through mailing list and also searched in
google and found that it can be
done with javascript onblur function but nothing is
working. Here is the code:
--
?php
include_once(inc\connection.inc);
//with this function first combobox will be populated
on pageload
function
display_db_combo($tablename,$columnname,$connection)
{
$query_string=select $columnname from $tablename;
$result=mysql_query($query_string);
while($row=mysql_fetch_array($result)) {
print(option$row[0]/option);
}
}
?
Do this again, only put the data for D2 and D3 in JavaScript arrays:
?php
function
dump_js_array($tablename,$columname,$connection)
{
.
.
.
print(script language=\javascript\\n;
print(\tvar D2 = array(''\n); //this is printing out JavaScript code
while($row...) {
print(\t\t,'$row[0]'\n); //elements of array (note '' above)
}
print(\t);\n); //end of JavaScript array
print(/script\n);
}
?
Then you can use the onblur() in JavaScript to pull data out of those
JavaScript arrays to populate D2 and D3.
You'll have to work out the JavaScript part somewhere else, as it's
JavaScript and not PHP, and I'd probably get it wrong.
HTML
HEAD
TITLEUntitled Page/TITLE
META NAME=Generator CONTENT=Created by BlueVoda
/HEAD
BODY bgcolor=#FF text=#00
DIV style=position:absolute; left:175px; top:70px;
width:592px; height:483px;
z-index:24 align=left valign=top
FORM name=form_cust method=POST
action=thisform.php
enctype=multipart/form-data
DIV style=position:absolute; left:198px; top:65px;
width:6px; height:15px; z-index:0
align=left valign=top
FONT style=FONT-SIZE:9pt color=#8B
face=ArialB:/B/FONT
/DIV
DIV style=position:absolute; left:198px; top:108px;
width:6px; height:15px;
z-index:1 align=left valign=top
FONT style=FONT-SIZE:9pt color=#8B
face=ArialB:/B/FONT
/DIV
DIV style=position:absolute; left:198px; top:167px;
width:6px; height:15px;
z-index:2 align=left valign=top
FONT style=FONT-SIZE:9pt color=#8B
face=ArialB:/B/FONT
/DIV
DIV style=position:absolute; left:65px; top:60px;
width:97px; height:22px; z-index:3
align=left valign=top
FONT style=FONT-SIZE:12pt color=#8B
face=Courier NewBService/B/FONT
/DIV
select name=D1 size=1
style=position:absolute;left:230px;top:68px;z-index:7
?php
display_db_combo(service_master,service_name,$conn);?
/select
DIV style=position:absolute; left:65px; top:106px;
width:83px; height:22px;
z-index:4 align=left valign=top
FONT style=FONT-SIZE:12pt color=#8B
face=Courier NewBProduct/B/FONT
/DIV
select name=D2 size=1
style=position:absolute;left:230px;top:108px;z-index:8
/select
DIV style=position:absolute; left:65px; top:152px;
width:103px; height:44px;
z-index:5 align=left valign=top
FONT style=FONT-SIZE:12pt color=#8B
face=Courier NewBNature of
Problem/B/FONT
/DIV
select name=D3
style=position:absolute;left:230px;top:170px;z-index:9
size=1
value=
/select
DIV style=position:absolute; left:177px; top:1px;
width:270px; height:22px;
z-index:9 align=center valign=top
FONT style=FONT-SIZE:12pt color=#8B
face=Courier NewBUComplaint
Registration/B/U/FONT
/DIV
INPUT type=reset name=Edit_Reset value=Reset
style=position:absolute;left:376px;top:429px;z-index:10
INPUT type=submit name=comp_send value=Send
style=position:absolute;left:148px;top:429px;z-index:11
INPUT type=text
style=position:absolute;left:230px;top:240px;width:161px;z-index:12
size=23
name=T3 value=
DIV style=position:absolute; left:257px; top:330px;
width:60px; height:18px;
z-index:13 align=left valign=top
FONT style=FONT-SIZE:12pt color=#8B
face=Courier NewBUpper/B/FONT
/DIV
DIV style=position:absolute; left:257px; top:359px;
width:72px; height:18px;
z-index:14 align=left valign=top
FONT style=FONT-SIZE:12pt color=#8B
face=Courier NewBMiddle/B/FONT
/DIV
DIV style=position:absolute; left:257px; top:386px;
width:60px; height:18px;
z-index:15 align=left valign=top
FONT style=FONT-SIZE:12pt color=#8B
face=Courier NewBLower/B/FONT
/DIV
DIV style=position:absolute; left:65px; top:240px;
width:123px; height:66px;
z-index:16 align=left valign=top
FONT style=FONT-SIZE:12pt color=#8B
face=Courier NewBProblem
Description/B/FONT
/DIV
DIV style=position:absolute; left:198px; top:240px;