Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Dynamic Dependent Drop Down Boxes


I need to build a dynamic page with 2 drop down boxes on it where the contents of the second drop down box are dependent upon the selection made in the first drop down box (the first box contains districts/regions and the second box contains towns/cities). The customer wants this to happen on a single screen but can this be done with PHP?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Dynamic Drop Down Boxes With Php Query
I need to build a dynamic page with 2 drop down boxes on it where the contents of the second drop down box are dependent upon the selection made in the first drop down box (the first box contains districts/regions and the second box contains towns/cities). The customer wants this to happen on a single screen but can this be done with PHP?

The above question is already answered by many people and they want me to use Javascript.
My doubt is the second box shoud query the list from a table in mysql using php. How do i do that?

Dynamic Drop Down Boxes With Mysql
I'm working on a database project for a class and am having problems populating select boxes with a field from a mysql table.  The first thing that I'm trying to do is pull the field LastName from the table Faculty.  Then when the user selects the faculty member in the drop down box, it will then display all of the fields related to that faculty member...first and last name, title, office number etc and allow the user to edit those fields and then resubmit them to the database.

However I can't seem to get the drop down box to populate, so if anyone has any suggestions as to how to fix this I would love to hear them. Code:

Dependent Drop Downs?
I have a drop down menu populated from a database. There are 3 other drop downs on the page that I want to populate from the database AFTER the user has made a selection in the first list. Can that be done? Are there any scripts for that anywhere?

Multiple Drop Down Boxes
I want to create two multiple drop down boxes, the first will display all the company names, once this has been selected all the stock information for that company will appear in the second drop down boxes.

Form Drop Down Boxes
I have a bunch of products i want to add to a database, i have a form to submit the products to the database.

What i need to crack is to have a drop down box for category 1 (beer or wine) and then automatically populate the drop down box for category 2 depending on the first selection

if cat1 = beer then cat2 options = Lager, Malt, Stout.
if cat2 = Stout then cat3 = Guiness, london, Old boot.
if cat3 = Guiness then cat4 = Bottle, Can.

I have four sub categories so need this to work on the fly before adding all info to the database ...

Drop Down Answer Boxes
how to insert drop down answer boxes (like the oes you get in questionnaires) into my cong, i can't seem to get the coding right or make anything appear in the box.

Generating Drop Down Boxes From Mysql
i'm using php with mysql. i need to be able to extract items out of my database and put them into a drop down box so that the data is dynamic.

In this example, i need to get all of the names from the name.office field into a drop down box to be used in further scripts/processess.

<html>
<head>
</head>
<body>

<?

$db = mysql_pconnect ("localhost", "XXXX", "XXXXX");

if (!$db)

{
echo "error: could not connect to database. please try again later";
exit;
}

mysql_select_db("XXXXXXX");
$query = "select name from office";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);

$row = mysql_fetch_array($result);

?>

</body>
</html>what goes here??? i have tried many things and not been able to get it to work.

Drop Down Boxes Change By Selection
what i'm trying to do is when a user selects a country say UK, all the uk states are displayed in another selection box below BUT if the US is selected all the us states are shown, this is on nion every friends/dating site just curious as to how this is done.

Filtering Selection In Multiple Drop Down Boxes
I want to allow a user to conduct a search on a database using multiple drop down boxes.
On the first page they will have a drop box filled with records from field A. Once they select which one they want, a second drop down box will then appear with records from field B which are present for field A (a filter).

What I want though is that the first dwon down box still appears on the second page, but shows the record that the user selected. What is happening now is that when the second page comes up, the first box shows the default selection rather than the selection that the user chose. My code for the drop down boxes is: PHP Code:

Drop Down Boxes Selecting Selected Option
i make a PHP Query select the one that has been selected in a drop down box? Code:

Drop Down Boxes Selecting Selected Option
I have this code to allow me to get the selected option selected in the dropdown. The option is stored in url variable the code i currently have is selecting everything. I am doing something wrong? Code:

Dynamic Combo Boxes
i have a problem with creating some dynamic combo boxes. i have a form and the user enters the number of printers required, on the recieving page i display that many combo boxes ready for their input...but the problem is its not generating the correct number of combo boxes for some reason. i think i'ts because i need to reset the cursor on the result set so it can whip through the printers again but am not sure. please see following code:

Dynamic Text Boxes
I have a form where field techs can close out service calls, Time in, time out, work done, who the tech is....ect...

Currently I have 20 fields for parts..... Part1 / Part1QTY....and so on to Part10 / Part10QTY.... the form emails, and it also feeds data into MySQL... so everything is working fine...

What I would like to do, is stream line it...so there is only 2 fields...part_number and qty....and when techs needs to enter more parts then click on a button that creates 2 new sets of text boxes for input....
thus allowing me to have them enter more the just 10 parts and qty's.

I thought about, maybe having a secondary form on my HTML page, with different sets of submit buttons, and they can enter 1 part at a time... but I could not get the secondary form Submit button to not clear the data in the primary form...so that didn't work for me.! I'm am basically stuck here... there maybe one or two other issues I have...but those are not so critical.

I do have a great deal of MS Access experience but this PHP is a totally different monster. For those who know access, it's very easy to add a new record in a subform and just keep adding records...which is sort of what I'm trying to do here.

Dynamic Listy Boxes
we are trying to  buid some dynamic list boxes.  Our  code that  generates the
listbox  creates  a string  containing the list box definition and the  last line of the  file is echo  $outstr. 

When we  execute this, the list box works fine. Now when we embed it into am html page  in this way: <?php  include statuslistbox.php   ?>, we get  errors  that  say "constant  statuslistbox.php  not defined"  The listbox define file has  the php brackets  top and bottom. The embeding html has no brackets other than the ones show above. It seems to make no difference  if the calling file  is a php extension html extension.

Dynamic Text Boxes With While Loop?
Basically I have a dynamic number of categories. Each of these categories requires a text box, therefore I have a dynamic number of text boxes. My question is if there is anyway using a while loop that this can be done?

<?
while ($nextcat = array.php($categories))
{
echo $nextcat;
$varname = $strip_tags($nextcat)
?>
<input type = textarea name = <? $varname ?>>
<? } ?>

Dynamic Number Of Text Boxes/insert
On page one I ask 'How many boxes do you want?' and I have a simple form - the code is below:

<form action="addhouses.php" method="post">
<input type="text" name="numimages" size="3">
<input type="submit" name="submit" value="Submit">
</form>

On the next page I want to display how ever many boxes they said on the previous page.
Let's say they choose 4 - there are then 4 boxes which allow you to browse to files on your computer. Clicking submit on this page takes you to the third page which uploads the files and inserts the filenames into the database. Currently the code I have on the third page works fine for a static number of defined boxes. It is: PHP Code:

A Dynamic Drop Down List
I need to create a dynamic drop down list. By this i mean that the webpage html form = select style will recieve all the values as based on a query to a mysql database. I have no problems quering the data base with PHP, But i need to make some kind of for loop that will add a new value to the selct form for each result from the database. my thought process go like this.

1. call data base to guery. (no problem)

2. make variable variables that will be created according to the number of results (these variables must be created according to results of query, not a problem i think)

3. make a form like this

<form action = ***** method = post>
<select name = ******>
<option value = "This is a query result"> This is a query result> //This is the part i need to using a for loop and variable variables
</select></form>

so my problem is part 3, cause is this all done in PHP, or if i had all these variables, can i do this in HTML? Can i make a for loop in PHP that would break into HTML during these parts?

Dynamic Drop-down Menus
I am developing an on-line booking system, and am designing a script which creates a booking "area". An area has the following fields:

Area Name
Day start time (the time of day bookings can begin e.g 9 AM)
Booking Time Slot (the length of time for each time slot e.g 30 mins)
Day Finish Time (the time of day bookings must finish e.g 6 PM)

What i require is a method for locking down the users input so that the finish time is a list that is created that is divisable by the number of minutes used for a booking time slot . e.g. if the start time is 9 am and each booking time slot is 30 minutes, then the user must select a finish time which is divisable by 30 i.e. either on the hour or half past.

I have looked at several methods for doing this but cannot decide what would be suitable.
Ideally I want the user to be able to select the start time from a dropdown (static html would do) the select a booking time slot (again a static html dropdown would surfice) and then a dynamic dropdown be created with a list of Day Finish Times.

My questions are these:

Is this the right way to go about doing this - are drop downs my best option? If so, is calculating the day end time list the best way to go? Would javascript be more suitable, rather than a php form?

Dynamic Drop Down Menu
I'm having difficulties displaying the MakeModelID for a row selected from a drop down menu I've populated from a table combining three attributes (Make, Model and Specification - for example Ford Transit LWB 350 HR). What I require is to capture in a variable, such as $MakeModelID, the ID for that record selected. Code:

Dynamic Associated Drop Downs
I wrote a function to pull country values from my MySQL database into my forms country drop down list. This works great. However, I want to also pull region/state data for my form's region drop down list whenever a country is selected/changed in the country form field.

I know I can do this with javascript but I want to do it with PHP only. Can I do like a onclick command on the country field and have it resubmit the query that populated the region field? I think this is possibe but not sure how to do it.

Dynamic Drop-down List In Array
Q. How do I create a dynamically-generated drop-down list for use in
an array.

I'm using PHP with a MySQL database (through phpMyAdmin)

My database table is called com_courses, and I want to pull the
distinct 'title' fields and have them appear as a drop down menu for
the user to select in a form.

Here is my array, with (at the moment) manually-entered 'titles'
(which I now need to be dynamically generated from my database field:
'com_courses.title'

array (
"coursetitle",
"Course Title:",
$EXTRA_SELECTLIST,

array ("Report Writing", "Recruitment & Selection", "Presentation
Skills", "Essential Telephone Skills", "Time Managememt", "Customer
Care", "Other"),
0
),

I am not an experienced programmer, but can play around with php to
customize programs. I've read up on arrays (I bought a "Programming
with PHP and MySQL" book, but it just stops short of this problem). I
can't figure this one out.

Multiple Dynamic Drop Down Population
I have a table with 3 pieces of data that I would like to use to
dynamically populate 3 drop downs using javascript. The fields are
state, orgname, office. If it's not already obvious, I'd like orgname
drop down to change when a state is selected and I would like office
drop down to change when an orgname is selected. I can do this with
multiple tables but am having difficulty getting it to work when the
data is in the same table. Below is the code to get state and orgname
from separate tables(the code reflects one table and is broken in the
below state). It's the best I can come up with and I can see why it
doesn't work but I know there must be a way to pull all the pieces from
a single table.

<code>
$list=$_SESSION['list'];
if(isset($list) and strlen($list) 0){
$quer=mysql_query("SELECT DISTINCT orgname,org_id FROM organization
WHERE state=$list ORDER BY orgname");
}else{$quer=mysql_query("SELECT DISTINCT orgname FROM organization ORDER
BY orgname"); }
$quer2=mysql_query("SELECT DISTINCT state FROM organization ORDER BY
state");

//first drop down
echo "<select name='state' onchange="reload(this.form)"><option
value=&#390;'>Select one</option>";
while($state = mysql_fetch_array($quer2)) {
if($state['org_id']==@$list){echo "<option selected
value='$state[state]'>$state[state]</option>"."<BR>";}
else{echo "<option value='$state[state]'>$state[state]</option>";}
}
echo "</select>";

//next drop down
echo "<select name='org'><option value=''>Select one</option>";
while($org = mysql_fetch_array($quer)) {
echo "<option value='$org[org_id]'>$org[orgname]</option>";
}
echo "</select>";
</code>

Creating Dynamic Drop Down Menu
I have a mysql database called Auditions with a table called Sept7. The table has two columns Time and Name. I want to create a dynamic pull down menu and populate it with items pulled from the table based on a query. Code:

Dynamic Drop Downs With Php And Java
I'm working on a project where I need the drop down menus to be dynamic almost identical.
I found a java code that looks to do what I want it to do. But, being that I know very little about this, I'm not sure what goes where.

Dynamic Drop-down List With Array - Question
Can anyone out there give me a pointer regarding creating a
dynamically-generated drop-down list connected to an array?

And is that question as clear as chocolate spread?

Here's what I've got. I'm using PHP and MySQL database. I'm customizing
some calendar software, and I want the user to fill in a form by
selecting a title from a drop-down list, generated by my MySQL
database. However, the program I'm customizing uses arrays, which is
where I'm stumped.

What do I need to add to this code to make the array of titles(eg
"report writing" etc) come from my database, rather than the
manually-entered values that you can see here.

The field I want to pull from is called com_courses.title

array (
"coursetitle",
"Course Title:",
$EXTRA_SELECTLIST,

array ("Report Writing", "Recruitment & Selection", "Presentation
Skills", "Essential Telephone Skills", "Time Managememt", "Customer
Care", "Other"),
0
),

I hope it's not cheeky to ask this,
BTW I bought a book on Programming with PHP and MySQL, but it doesn't
answer this question,

Dependent Includes?
i've got a page someone else built with an include for another file. the include needed a random banner, both jpeg and swf.

so i figured that one out - i've set up an include in that file which calls the proper code randomly from a text file, one line with the embed for the swf and one line with the image (both in their own link tag - a href...)

so here's the issue -

back on the top level, there's another banner which needs to be dependent on the include inside the include.  they're in 2 completely different places, so tying them into the same file is not an option.

Dependent Select Menus
I would like to create a form in which a 2nd select box appears
depending on the value selected in the 1st select box. The values of
the 2nd select box will come from a database.

My question is how to create this in php? One way is to re-load the
page depending on what's chosen in the first box, or alternatively to
use frames or an iframe?

Is there another, better way that can dynamically change the initial
page?

Selected Value In Dropdown Dependent On Database Value
i need a way to make the selected value of a drop down dependend on a result from a database query. PHP Code:

Substr With Dependent Length Parameter
Is it possible to use substr() to get only the letters displayed after numbers (at the end of a string)? For example:

WA-0318a would give me a
SAN-2011Aa would give me Aa
KE-2200Eb would give me Eb

So, if $variable = "SAN-2011Aa" then substr($variable, -?). The negative length parameter would be dependent on how many of the ending characters are letters and not numbers. In this case, I would need to dynamically generate 2 (for -2). In the case of "WA-0318a" I would need to dynamically generate 1 (for -1).

Is this possible?

Drop Down Lists Changing Depending On Other Drop Downs
I want to have a drop down system like this one.  But without the radio buttons.

I want to have 3 drop downs but have no idea how to go about it.  I assume I will need to activate some sort of Javascript on the onChange event of the option drop downs.

Check Boxes
I have a very little problem with check boxes. How can I write a simple PHP code to tell me when a check box has been checked, and then use the name of the checkbox in a function.

Reading POP Boxes
I've been looking round for something that will read the contents of a pop
box and populate a MySQL table.

The e-mails will all be of a fixed format and include a jpeg as an
attachment. I need to put the following columns in:

sender
subject
body
filename (possibly appended to the date to mitigate the risk of
The script would also need to save the attachment to a predetermined folder.

Does anyone know of anything that would do this? Alternatively, how much
would it cost for someone to get this working for me?

Alert Boxes
do u know the alert box in javascript?

when u write alert("somthing");

well i need that in php what is the alternative function for that in php?

Combo Boxes Question
I am wondering how I can make the whole array appear in the code that is below with the database entry to be selected. At the moment it just displays the database entry.

Populating Two Combo Boxes
I have one combo box (Category) which is populated by a MySQL table using php. I am trying to use the onchange javascript to submit the value selected so that I can populate the other combo box (sub-category) based on what was previously choosen. So can anybody give me a clue on how to submit the first boxes value so that the second can see what was selected (javascript function).

An Array Of Text Boxes
I have the full code in a php script where I essentially display a form with checkboxes, and 2 text boxes associated with each checkbox to record grades ( marks and remarks ). The form displays correctly and the checkboxes I select do pass the correct id numbers for the students to be graded, also the numeric data in the first textbox is correctly transmitted HOWEVER the data in the second textbox gets randomly truncated.

e.g, if the "remarks" textbox has 'hello', it gets truncated to 'o'. It seems I'm not resetting something or there is another simple oversight somewhere, perhaps the script treating the data as a string rather than as an array Code:

Printing Colored Css-boxes
I've got a page with a couple of tables inside a couple of colored boxes(css-style), but when I try to print the page I end up with a copy without colors.

Conditional List Boxes
I am attempting to create a list box that is dynamically populated based on the selection of another list box.  I am in way over my head..only way to learn I guess.  The code below has a year listbox and then based on the year selection, the page should either show another listbox (show industry selection when year <> 2005) or it should render the main form (when year=2005). I cannot get the main form to appear. Code:

If Statement And Check Boxes.
I have a database full of different articles/stories. I would like to have a publish check box so that if it is checked, that story appears on the homepage, I know how to do this. HOWEVER, i need ot be able to limit this so that only one can ever be checked off... Code:

Spaces In <input Text> Boxes.
When I submit a form where a user has typed a space into the input box, then check that value in the action .php file, only the text before the first space is displayed. How can I get all of the text sent?

eg

Code:
<form name="form2" method="post" action="temp.php">
<input type="text" name="name">
<input type="submit" name="Submit" value="Submit">
</form>

Then in temp.php
Code:
echo "Username = $name";

If the user enters "Greg Bennet" into the text field, I get back "Username = Greg".

Dynamically Filling Selection Boxes
I was wondering if anyone knows how to fill a selection box with different values depending on a selection made in a nother selection box in the same page. I dont know if what I'm tryin to do can be done or not, at least in PHP. First a quick background:

We have a number of projects running right now, each of which is subdevided into various tasks. Now, I've got two selection boxes. The first contains a list of all current projects. What I want to do is this: when someon selects a project from the first box, I'd like the second box to be filled with a list of the tasks that have been assigned tot hat project.

Using Mail() And Avoiding Spam Boxes !
Im using the mail() command to send an email to people who register on
my site, but many are ending up in people's spam boxes on hotmail.

This problem isn't true of all users - probably around 60%.

Im being as open as possible using a number of headers, but can anyone
suggest a way of getting through with less problems ?

$sender = "From: Name <email@domain.com>" . "";
$sender .= "Return-Path: email@domain.com" . "";
$sender .= "MIME-Version: 1.0" . "";
$sender .= "Content-Type: text/plain; charset=iso-8859-1" . "";
$sender .= "Content-Transfer-Encoding: 8bit" . "";
$sender .= "X-Mailer: PHP/" . phpversion();

Passing Values From Text Boxes
what I'm trying to do is pass some values from text boxes, yes it may sound simple, but let me explain more... I've got a form, and what I want to do is that when you enter a new question and select a existing category from the drop down box, it then inserts the values into the database no problem. However if enter a new question, and a new category, then submit the info, I get a null value. The Code...

Handling Multiple Check Boxes
I have a PHP generated page which displays X many records. Each record has
a checkbox preceding it. The user checks several checkboxes, and hits a
delete button. All the corresponding records will be deleted.

But I'm running into difficulty...

Right now the NAME property of each check box is the primary key of the
corresponding record. Hence if I know which checkboxes are checked, I
simply use DELETE using the NAME value.

Generally speaking, how do I get the server side to see which check boxes
were checked?

The check box names may not be sequential, if any records have been deleted
previously, and the first check box might be a number greater than 0.

Is there an easy mechanism to do this? Some kind of built in cnotrol array
allowing me to loop over every check box that was on the form submitted?

I could store the last and first checkbox number in a hidden input, then
loop starting/ending at those values, but that may loop over a lot of
controls that do not exist.

Checking Check Boxes From Post
I have a group of five checkboxes that I need to check in a script after a
post-operaiton. I was using the code:

$drv1 = $_POST['driving_1']

but if the user left checkbox "driving_1" empty, i get a php error upon
processing. So, I looked in the manual and found the fuction empty(). So I
tried:

If (empty($drv1)) {
then do this
}

But it doesn't seem to be working. Actually, what I really want is if not
equal to empty, something like:

If (!empty($drv1)) {
then do this
}

Punctuation Marks In PHP Text Boxes
I am not a PHP user; I manage the server/ network for our business.
We've employed web developers (chosen because they're friends of the
MD) to build us a site and they've used PHP & MySQL to do it.

The problem we have is that if we use an apostrophe when writing a
product description or product title in the back office of our site,
when that data is then used or carried through to another part of the
site eg. a live product page or an order summary page, the apostrophe
has a backslash before it. We have run into other issues with the use
of various punctuation marks in the text fields of the back end of the
site and have always been told by the developers that it is a fault of
PHP and is common with PHP text fields.

Now, as I said, I'm not a PHP user and certainly no expert. But I have
installed and used Mambo Server, Wordpress, phpBB and a couple of other
PHP MySQL products through my own curiosity and have done so
successfully and have never experienced any of the issues we seem to be
facing with these text boxes. I am growing increasingly suspicious of
the level of competence of the developers and feel that they are making
excuses for their inability. Can anyone tell me, from what I've said
here, whether my suspicions are justified or is it the case that PHP is
limited in these areas?

Selections On Dropdown Selection-boxes
I have a article manager script that im nearly done with and when you press save, it takes you to another page to check that you have entered the required fields by checking for the POST vars, if not it redirects back to the page and stuffs the entered fields into GET vars header( location: file.php?errors=$errors&var1=$var1 ) 's you back to the previous page.

Now i have no trouble reshowing the entered info in regular text fields as i grab it from GET but i dont seem to be able to reshow a drop down box selection it always reverts back to the first option when i redirect the page.

Avoiding Php Mail() To Spam Boxes
I'm sending soliticited emails for a nonprofit and i'm finding when i use PHP's mail function, and the mail goes through my ISP's SMTP, a decent percentage of the mails go to people's spam boxes.

are there known headers or something i could add to my code to make them less spam box prone?

Long Strings In List/menu Boxes
Is there a way to get a list/menu box to resize as the page is resized and
for any long string that is an item in the list to be spread over two or
more lines in the same way as text in a table does.


Copyright © 2005-08 www.BigResource.com, All rights reserved