Jump to content

Archived

This topic is now archived and is closed to further replies.

devofash

**SOLVED** combo box help !!

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

Share this post


Link to post
Share on other sites
To make life easier, try the baaSelect link in my sig, or use [a href=\"http://members.aol.com/barryaandrew/xmlhttp/article.html\" target=\"_blank\"]xmlhttp request[/a]

Share this post


Link to post
Share on other sites
phew.... i'm quite a newbie to all this can hardly do simple stuff ... the links u mentioned looks quite complicated. dont really know any jscript either, can it not be done with just plain php ... ?

Share this post


Link to post
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]

Share this post


Link to post
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.....

Share this post


Link to post
Share on other sites
.... basically if a user clicks on "Human Resources", i want the [b]combo box[/b] to list all the jobs in that department => "clerk" and "manager".

Above is extract from your first post.

So what output do you want?

Share this post


Link to post
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......

Share this post


Link to post
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 :)

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]but instead i need to do '?page=display_jobs'.[/quote]

Why?

Share this post


Link to post
Share on other sites
because in all the other pages that i've got i've done that.... need to stay consistent..... and i thought using the query_string thing was efficient.

Share this post


Link to post
Share on other sites
?page=display_jobs

will return you to the same page with "display_jobs" in $_GET['page']

But you aren't doing anything with $_GET['page'] in the script !

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Then the form action needs to be something like

[code]action='index.php?page=display_jobs'[/code]

But you will also need a way of passing the selected department.

Share this post


Link to post
Share on other sites
action='index.php?display_jobs&department=$id'

is that it... but its not working either

soz this is very embarassing but how do i do that....? ..... dont get combo boxes shoul've never used it in the first place

Share this post


Link to post
Share on other sites
i've done it ........ was really tired yesterday ..... couldnt think properly........

thread SOLVED ....... thanx once again barand for all the help :)

Share this post


Link to post
Share on other sites

×

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.