Current location: Hot Scripts Forums » General Web Coding » JavaScript » Need help populating 2nd Select box with JavaScript


Need help populating 2nd Select box with JavaScript

Reply
  #1 (permalink)  
Old 06-22-04, 05:27 PM
jomama13 jomama13 is offline
New Member
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Need help populating 2nd Select box with JavaScript

I need help populating a list box called 'SubCategory' with results from a db query. The list box should only have results that apply to the first select box called 'Category'. In short this is how I would like to do it but I don't have the technical prowess to complete the JavaScript programming part of it.


//DB QUERY 1 for Categories to populate select box named 'Category'

//DB QUERY 2 for SubCategories to later populate the JavaScript array below to be accessed later by a function in an onChange (or equivalent) JavaScript call attached to the first select box(Category).


=>NEED HELP HERE<=
//JavaScript array with values from DB Query 2(fields: CategoryID, SubCategoryID, SubCatDesc)
//JavaScript function
=>NEED HELP, DON'T KNOW HOW TO DO IT<=

//FIRST SELECT BOX
<select name="Category" onChange="javascript:UpdateSubCat(this.value);">
<option selected>Select One</option>
<?php
$i=1; //initliaze a counter
while ($rows=mysql_fetch_array($result1)){

//assign the data to some variables - not really needed but clearer when coding
$catid= $rows['CategoryID']; $catdesc=$rows['CategoryDesc'];

echo "<option value=" . $catid . >" . $catdesc . "</option>";
$i++; //increment the counter

} //close the while loop

?>
</select>
//END SELECT #1

<select name="SubCategory">
//DON"T KNOW HOW TO POPULATE THIS
</select>


Please help in any way possible. I know there are many ways to do this but this is the way I want to approach it.

Thanks in advance for all of your help

Joe
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using 'SELECT from' with value from a text box. steve711 PHP 1 06-17-04 06:37 PM
passing value from JavaScript scorpioy PHP 0 05-22-04 07:31 PM
Reaaly stuck about javascript over frames muratisik JavaScript 1 12-14-03 11:58 AM
i have 3 select box this is urgent traceMe JavaScript 0 12-02-03 01:24 AM
Javascript vs PHP, problem with arrays Chuff JavaScript 0 10-03-03 04:01 AM


All times are GMT -5. The time now is 10:24 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.