473,396 Members | 2,010 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,396 software developers and data experts.

Drop down box onchange in php

44
Sorry about the title wasn't sure how to describe my issue in short form.

My problem is this.

I have a dropdown box that is populated from a mySQL database. The reason for this is there are a significant number of options available and much easier to do than code all the options individually.

When the user clicks an option in the drop down box I want the details of some text boxes to change according to the corresponding data in the database to the option the user has clicked.

Hope that makes sense so far.

I am using PHP and mySQL. I understand that Javascript is the way to go, unfortunatly I have not done any other than a few basic tutorials today. I will add the code I have for popultaing the drop down.

[PHP]
<form name="makeorder" action="" method="post">
<label>Select material: </label>
<select id="material" name="material">
<?php
$sql = "SELECT * FROM upload";
$result = mysql_query($sql, $db);

echo '<option value="">Select</option>';

while ($row = mysql_fetch_assoc($result))
{
$mat = $row['mat'];
echo "<option value='$mat'>$mat</option>";
}
echo '</select>';
?>

</form>
[/PHP]

So if the user clicks option 5 then the page will reload and the details relating to that item will be displyed somewhere on the page.

Many thanks in advance

Badvoc
Apr 2 '08 #1
4 4847
ronverdonk
4,258 Expert 4TB
You almost have the same problem as THIS THREAD . Except you want to fill a textbox instead of generating option statements.

Have a look at that thread and the proposed tutorial on Ajax chained select. After that come back here to discuss any particular problems you have with your code.

Ronald
Apr 3 '08 #2
badvoc
44
Thanks I'll have a look and come back to you.

I am only looking for pointers and advice not answers so thank you for directing me to help rather than showing the answers. I have used this forum before and it's always my first point of call after google that is.

Cheers
Apr 3 '08 #3
ronverdonk
4,258 Expert 4TB
As long as you feel helped or pointed in the right direction. See you then.

Ronald
Apr 4 '08 #4
badvoc
44
[font=Arial]Cheers Ronald. I was helping a friend with a project he is doing for his degree and we sort of sorted it but went with a different method that was easier for him to understand and implement into his project.[/font]


Many thanks
Apr 9 '08 #5

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

Similar topics

1
by: Greg Scharlemann | last post by:
I would like to automatically populate a drop down menu when the page loads based on the selection of an item in a different drop down menu. I made a test page that when drop down #1 changes, drop...
4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
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...
1
by: Capitan Catarro | last post by:
Hi everybody, I have a little problem with drop down menus. I have a PHP page in which I extract some categories (from a database). I put those categories in a drop down menu without problems. I...
4
by: tjonsek | last post by:
I have two drop down boxes on a form. One feeds the second a list options based on user selection. With the second drop down, I want code that displays dynamic text in a <div> based on whatever the...
7
by: slekshmipriya | last post by:
Hai friends.I have a pblm with my drop down list onchange event.The pblm is as follow I have a drop drown list with items 1,2 ,3 etc. On selecting an item from the drop down list i want to...
13
by: ikilldeath | last post by:
Hi, I am very much new to JavaScript. Please, can anyone help in resolving this issue. Here in the example http://www.javascriptkit.com/script/script2/flipmenu.shtml There are two folders:...
7
controlbox
by: controlbox | last post by:
I have recently inplemented some drop-down lists (combos) on a page where one is dynamically populated according to the selection of another using the microsoft ajax extensions. I had to set...
15
by: ajos | last post by:
Hello all, Im making a dependent drop down for my application for filtering purpose. I have populated the drop down from the database and retrieved in the html. <tr> <td valign="top"...
6
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.