Jump to content

**SOLVED** combo box help !!


devofash

Recommended Posts

hey guys ... how's it going ??

newbie here got a question ..... need a little help with combo box, here's what i need the combo box to do. Firstly i have 2 tables "jobs" and "department". A job in jobs table has a reference no. which refers to a department id in the department table. i'll give an example

sorry not very good at explaining hope i'm making sense so far. right i need the combo box to list all the department names (i've done that already, u'll c the code below).... basically if a user clicks on "Human Resources", i want the combo box to list all the jobs in that department => "clerk" and "manager".

hope u guys can help me out :D.... thanx
Link to comment
Share on other sites

The baaSelect class will write the required js code for you

All you need is

[code]<?php
include 'baaselect.php';
include 'db.php'; #database connection

$sel = new baaSelect();

$sel->addSelect('department', 'department', 'dept_id', 'department','',BY_TEXT,'--select department--');
$sel->addSelect('job', 'jobs', 'jobid', 'jobTitle','department',BY_TEXT,'--select job--');
?>

<HTML>
<HEAD>
<meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)">
<title>Sample</title>

<? $sel->makeScript(); ?>

</HEAD>
<BODY>
<form method=get>
<?
$sel->makeSelect('department');         # this creates the HTML
$sel->makeSelect('job');
?>
</form>
</BODY>
</HTML>

[/code]
Link to comment
Share on other sites

oo cool....... it works.... :)

but its not exactly what i want though :( ...... soz i think its sorta my fault prob. didnt explain everything properly

ermm right now it displays all the department (click department and it displays all the jobs in that department) ...... but i dont want the jobs to be displayed in another combo ..... i need it to display it in an page... with some other job details.....

Link to comment
Share on other sites

sorry ... i sorta ment that ... i'll start again

when a user clicks human resources, i want the combo box to display all the job details of the clerk and manager in a page (the jobs table has other fields) need them to be displayed too ...

thanx in advance for the help......

Link to comment
Share on other sites

hmm solved......

i just passed the value to another query .... used get to get the value....ran a query on that value and displayed the matching records :) ............. cant believe i didnt thing of tht before... it just didnt crosss my mind :duh:

thanx barand........ apreciate ur help :)
Link to comment
Share on other sites

dont want to make another thread .... just need a little help with somethin ... its related to this topic so... here goes. the script listed at the end ... works fine .... except for one little problem .. the problem:

when i do this it works fine ....

[code]
      <form name = 'form' method='GET' action=display_jobs.php >
[/code]

[code]
      <form name = 'form' method='GET' action= <? ?page=display_jobs ?> >
[/code]

^^ but when i do this it doesnt work. i need to use this method instead of the first one

can anyone help ... plz ......


thanx
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<form name = 'form' method='GET' action= <? ?page=display_jobs ?> >[/quote]

Why is the action in php tags when there is no php code?

[code]<form name = 'form' method='GET' action='?page=display_jobs'>[/code]
Link to comment
Share on other sites

[!--quoteo(post=364625:date=Apr 14 2006, 12:06 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 14 2006, 12:06 AM) [snapback]364625[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Why is the action in php tags when there is no php code?

[code]<form name = 'form' method='GET' action='?page=display_jobs'>[/code]
[/quote]

still doesnt work. if i put <form action = 'display_jobs.php'> it works perfectly..... but need to use QUERY_STRING so have to put <form action = '?page=display_jobs'> ...... but still doesnt work ... so dont know wth to do ...?

basicallly all i need to do is get data from a database table into the combo box, when user clicks a record .... alll the data related to that record is displayed into a page. i.e.... user picks "Human Resources" presses submit... all the jobs from tht department is displayed into another page. script works if i put 'display_jobs.php' but instead i need to do '?page=display_jobs'.... any help will be appreicated :D .......

also i would much appreciate it if someone can tell me if the above posted code can be made better or if there's a shorter way of doing what i've done. thanx in advance
Link to comment
Share on other sites

i have an index page where i've got somethin like this

[code]$page = $_GET['page']
switch($page)
{
  case "display_jobs":
  include('display_jobs.php');
  break;
}[/code]

but dont c wht that one has to do with this script... ? ... how do i get this one to work.. sorie i'm being really silly just get very frustrated when my code dont work and i start being dumb :S
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.