473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Dependant Drop Down Box

4
Ok, I am trying to populate two drop down boxes with the results of a query. I have the first one set up and working but I am stuck on how to pass the results of the first query as a constraint for the second as there is no submit and every example I can find on the web only shows how to pass via post/get into another page. :mad:

Here is what I have for code:


Below are the functions that display the results of the query in a table.
Expand|Select|Wrap|Line Numbers
  1. function dd_joblist($user_name)
  2. {
  3.     $result=mysql_query("SELECT DISTINCT job_name FROM oats_jobs_users_laborCode where user='$user_name' order by job_name;"); 
  4.     if($result)
  5.     {
  6.         echo "<select name=\"job_select\" onchange=\"$job_select=reload(this.form)\"> <option default=\"default\" value=\"*\">Choose One</option>"; 
  7.         while($row=mysql_fetch_row($result))
  8.         { 
  9.             echo "<option value=\"$row[0]\">$row[0]</option>";
  10.         } 
  11.             echo "</select>";
  12.     }
  13.     else
  14.     {
  15.         echo mysql_error($result);
  16.     }
  17. }
  18.  
  19. function dd_laborlist($user_name, $job_select)
  20. {
  21.     $result=mysql_query("SELECT DISTINCT labor_code FROM oats_jobs_users_laborCode where user='$user_name' and job_name='$job_select' order by job_name;"); 
  22.     if($result)
  23.     {
  24.         echo "<select name=\"laborcode\" > <option default=\"default\" value=\"\">Choose One</option>"; 
  25.         while($row=mysql_fetch_row($result))
  26.         { 
  27.             echo "<option value=\"$row[0]\">$row[0]</option>";
  28.         } 
  29.             echo "</select>";
  30.     }
  31.     else
  32.     {
  33.         echo mysql_error($result);
  34.     }
  35. }
  36.  
This is a js that is (hopefully) reloading the page and seems to be storing the first value.
Expand|Select|Wrap|Line Numbers
  1. function reload(form)
  2. {
  3.     var val=form.job_select.options[form.job_select.options.selectedIndex].value;
  4.     self.location='options_screen.inc.php?job_select=' + val ;
  5.     return val;
  6. }
  7.  
This is the HTML code that calls the php functions
Expand|Select|Wrap|Line Numbers
  1. <td><?php dd_joblist($user_name) ?></td>
  2. <td><?php dd_laborlist($user_name, $job_select) ?></td>
  3.  
I am almost to the point of pulling my hair out. Any help would be greatly appreciated
Jul 18 '06 #1
2 3706
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <select onchange="window.location='select.php?language='+this.value">
  2. <option value="0">- Select Language -</option>
  3. <option value="1" <?if ($language == 1) {?>selected<?}?>>English</option>
  4. <option value="2" <?if ($language == 2) {?>selected<?}?>>Chinese</option>
  5. </select>
  6.  
heres a way to pass the selected value to a page of your desire --- the value can be retrieved by
Expand|Select|Wrap|Line Numbers
  1.  <? $language = $_GET["language"]; ?>
i think this is what you are looking for good luck and let me know if you have any problems with this
Jul 18 '06 #2
JimS
4
Expand|Select|Wrap|Line Numbers
  1. onchange="window.location='select.php?language='+this.value"
  2.  
I am assuming this reloads the page back into itself?
Jul 20 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first...
2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
1
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the...
3
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
1
by: pmelanso | last post by:
Hello, I have a drop down list which is dynatically loaded from a database and I have a second drop down list that is also dynatically loaded depending on what is selected in the first drop down...
7
by: callawayglfr | last post by:
I am building a database in access where I have a drop down box that relates to a text box, that part I have working but when someone selects information from the first drop down I need it to limit...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
3
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.