need help!
| From: | its me | Date: | Sun, 10 Mar 2002 06:01:23 +0000 |
| Subject: | need help! | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-80958@lists.php.net to get a copy of this message | ||
i have in java script an array:
var computerArray = new Array("('Select sub-category','',true,true)",
"('Hardware')",
"('Monitors')",
"('Printers')",
"('Other')");
but i want to create the items:
"('Hardware')",
"('Monitors')",
"('Printers')",
"('Other')
dynamicaly from database
and this array must stay in javascript i can't create it with only php because its elements
are a drop down menu which change with the change of another drop down menu..so it must remain in
javascript...
the whole script is:
<script language="JavaScript">
<!--
var computerArray = new Array("('Select sub-category','',true,true)",
"('Hardware')",
"('Monitors')",
"('Printers')",
"('Other')");
var carsArray = new Array("('Select sub-category','',true,true)",
"('Vans')",
"('Sedan')",
"('Spor')",
"('Other')");
function populateCategory(inForm,selected) {
var selectedArray = eval(selected + "Array");
while (selectedArray.length < inForm.subcategory.options.length) {
inForm.subcategory.options[(inForm.subcategory.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval("inForm.subcategory.options[i]=" + "new Option" + selectedArray[i]);
}
if (inForm.category.options[0].value == '') {
inForm.category.options[0]= null;
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0);
}
}
}
}
}
// End -->
</script>
<html>
<BODY bgcolor="#FFFFFF" text="#000000">
<center>
<form name="globe">
<select name="category"
onChange="populateCategory(document.globe,document.globe.category.options[document.globe.category.selectedIndex].value)">
<option selected value=''>Select Category</option>
<option value='cars'>Cars</option>
<option value='computer'>Computer</option>
</select>
<select name="subcategory">
<option value=''><--------------------</option>
</select>
</form>
</center>
</SCRIPT>
Rehab M.Shouman
------------------------------------------------------------
------------------------------------------------------------
---------------------------------------------------------------------
Express yourself with a super cool email address from BigMailBox.com.
Hundreds of choices. It's free!
http://www.bigmailbox.com
---------------------------------------------------------------------