Dynamic Dropdowns problem
Posted: Fri Aug 27, 2004 10:05 am
feyd | Please use
The big problem i have is when someone wants to edit his profile and get out the data from the database so what i want is that the selected item in the selectbox is the same as in the database but because i use a mix of php and javascript. I don't know how to fix it.
I have found this dropdown info here => http://www.felgall.com/jstip22.htm
The only problem i have is to set the selected item the same as the data from the database.
feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hello,
I'm having a problem with my dropdown boxes =>Code: Select all
<SCRIPT LANGUAGE="JavaScript">
function setOptions(chosen) {
var selbox = document.form1.provincie;
selbox.options.length = 0;
if(chosen == "1") {";
$result = mysql_query("SELECT * FROM provincies WHERE land_id=1 ORDER BY naam ASC");
while($row = mysql_fetch_array($result))
{
$provincie_id = $row["id"];
$provincie_naam = $row["naam"];
echo "
selbox.options[selbox.options.length] = new Option('$provincie_naam','$provincie_id');";
}
}
echo "
}
if (chosen == "2") {";
$result = mysql_query("SELECT * FROM provincies WHERE land_id=2 ORDER BY naam ASC");
while($row = mysql_fetch_array($result))
{
$provincie_id = $row["id"];
$provincie_naam = $row["naam"];
echo "
selbox.options[selbox.options.length] = new Option('$provincie_naam','$provincie_id');";
}
}
echo "
}
//-->
</SCRIPT>The big problem i have is when someone wants to edit his profile and get out the data from the database so what i want is that the selected item in the selectbox is the same as in the database but because i use a mix of php and javascript. I don't know how to fix it.
I have found this dropdown info here => http://www.felgall.com/jstip22.htm
The only problem i have is to set the selected item the same as the data from the database.
feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]