Hi guys,....
I've a problem around here. i need 2 make double selection using 2 comboboxes. i've tried with javascript, and php of course, but i need to join them. the case is when i choose the first combobox, i'd like to query the second one by retrieving data from MySQL database. so i think i've to use "onChange" event at the first combobox, right ? (correct me if i'm wrong). If i just use php syntaxes, any of u can help ? Here is my two files :
1.
<head>
<script language="JavaScript">
<!--
//checking to see if user has NS or IE
IE = (document.all)?1:0
NS = (document.layers)?1:0
if(navigator.appVersion.charAt(0)< 4){
alert("sorry your browser isn't able to read this page")
history.go(-1)
}
var SportsTeams = "Chicago Bulls, Manchester United "
var MusicGroups = "Rolling Stones, Beastie Boys, Led Zeppelin, Nirvana, Pink Floyd"
var Beverages = "Jack and Coke, Corona, Newcastle, Brass Monkey, Gin and Juice, Snapple, Slurpees"
function createBox(x){
var category = new Array()
category = eval(x.menu.options[x.menu.selectedIndex].value).split(",")
var temp = '<form><select name = "menu2"><option>'
for(y = 0;y<category.length;y++){
temp += '<option value =' + category[y] + '>' + category[y]
}
temp +='</select></form>'
if(IE){newBox.innerHTML=(temp)}
else if(NS){
document.newBox.document.write(temp)
document.newBox.document.close()
}
}
//-->
</script>
<title>New Page 18</title>
</head>
<body>
<form>
<p><select name="menu" onChange="createBox(this.form)" size="1">
<option> </option>
<option value="SportsTeams">Best Teams </option>
<option value="MusicGroups">Best Music </option>
<option value="Beverages">Best Drinks </option>
</select> </p>
</form>
<div id="newBox" style="position:absolute; top:15;left:120;"></div>
</body>
- ==========================================================================================
PHP file
<form method=post action="<?$PHP_SELF;?>">
<select name=countrysel>
<option value="">Select Country</option>
<? require "conn.php3";
$res=mysql_query("select id,name from country");
while($row=mysql_fetch_row($res)) {
?>
<option value="<?echo $row[1];?>" onChange="selected()"> <? echo $row[1]; ?> </option>
<? } echo "</select>";
echo "<input type=submit value=\" Go \">";
if ($countrysel!="") { echo "You've select <b>$countrysel</b><br>";
echo "<select name=categorysel>";
echo "<option value=\"\" selected>Select Category</option>";
$res=mysql_query("select id,name from category where name like '%$countrysel%'");
while($row=mysql_fetch_row($res)) {
?>
<option value="<?echo $row[0];?>"> <? echo $row[1]; ?> </option>
<? } echo "</select>"; } ?>
</form>
===============================================================================================
can i use a form in a form ?
Thx
Andri