473,698 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a dynamic drop down box

19 New Member
I have created a php form with dynamic drop down boxes in it which pull the options from a database. The boxes work fine and the data gets submitted fine but im having a problem getting the box to default to a record of my choice from the database. (record 1 = None).
Here is the code to what i have done.
Expand|Select|Wrap|Line Numbers
  1. <input maxLength="40" size="30" name="name"></td>
  2.     </tr>
  3.     <tr>
  4.       <td width="286" height="22"><b>Person Involved:</b></td>
  5.       <td align="left" width="365" height="24"><select name="person_involved">
  6.  
  7.         <?php
  8.  
Expand|Select|Wrap|Line Numbers
  1. hesk_dbConnect();
  2. $sql = "SELECT * FROM `hesk_involved` ORDER BY `name` ASC";
  3. $result = hesk_dbQuery($sql);
  4. while ($row=hesk_dbFetchAssoc($result))
  5. {
  6.     echo "
  7.     <option value=\"$row[name]\">$row[name]</option>
  8.     ";
  9. }
  10.  
Expand|Select|Wrap|Line Numbers
  1. ?>
  2.       </select></td>
  3.     </tr>
  4.  
Hope you guys can help me out as im pulling my hair out now.
Oct 1 '07
31 8320
DirtySnipe
19 New Member
Ok looks like were moving forward now on this but there is still a problem.

It is not sending the selected item from dropdown. It is looking for the select name of involved.

Here is the code so far, I hope you can help.

[PHP]<tr>
<td width="286" height="22"><b> Person Involved:</b></td>
<td align="left" width="365" height="24"><se lect name="involved" >

<?
hesk_dbConnect( );
$sql = "SELECT * FROM `hesk_involved` ORDER BY `name` ASC";
$result = hesk_dbQuery($s ql);
while ($row=hesk_dbFe tchAssoc($resul t))
{
$sel = $row['isDefault'] == true ? "selected='sele cted'" : "";
?>
<option <?=$sel?> value="<?=$row['name']?>"><?=$row['name']?></option>
<?
}
?>


</td>
</tr>[/PHP]
Oct 8 '07 #31
DirtySnipe
19 New Member
hahaha lol

Duuuu

i got the select name wrong at the start.

Sorry about that.

Thanks alot this works great.
Oct 8 '07 #32

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

Similar topics

2
1761
by: xxbmichae1 | last post by:
I am writing a function that will create different type of input ranges, example one function that will create date range inputs with drop down calendars, another will be for currency ranges, another for uppercase input, etc.... anyway, the drop down calendar I am using has a javascript you call after the html of your edit box and object to click on to drop the calendar....is there a way or is it correct to say, that if you use innerHtml...
1
1688
by: ayende | last post by:
Okay, I'm pretty sure that I'm doing everything right here, but something is very wrong in the result. I've a page that has a drop down list (with auto-post-back = true) and a place holder. During page load, I'm loading a control dynamically (using LoadControl()) and adding it to the place holder. In the control OnInit(), I load some values into it.
1
1579
by: daveyand | last post by:
Hey guys, I am currently stuck, i am trying to create a function that will create a fresh new drop down option box dynamically. What happens is the user can double click an element on the page, when they do this function should be called and create the drop down. I can do the innerHTML stuff, i know how to add new options but am stuck as to how to create the initial object in the first place.
6
8301
by: mcgrew.michael | last post by:
I hope this is the right group. I am very new to ASP so this is probably a stupid question. I have some vbscript that query's AD and populates a recordset. I know the recorset contains the information I want by doing a Response.write. I am having problems dynamically creating a drop down list from the data in the recordset. The drop down is created but it is empty. Any help would be greatly appreciated. A sample of the code: <% 'On...
2
1792
by: Jim Gregg | last post by:
Hello all, I am faced with some logic that I am unsure how to handle. Imagine that I am running a WMI query and I am outputting the data into a dynamically created ASP table control. Here is my code that does this. I have left out the portion that connects to my server and the query, but this should be enough to show what I am doing. Basically it is a web page that queries SMS for clients in a certain collection, then outputs the name...
2
4333
by: vinceboy | last post by:
Hi anybody. I am newbie here and would like to know that how can I validate both drop down menu and radio button from a dynamic display form.Something went wrong with my script.The radio button is dynamic,however drop down menu is static. <script language="JavaScript" type="text/JavaScript"> function formSubmit(obj) { var returnStatus = 1; if (obj.rNumber.selectedIndex == 0 || !(movieList.time;?>].checked)) {
1
3463
by: bytesFTW99 | last post by:
I have been struggling with this for some time can anyone help out? just trying to have 3 dropdown boxes that fill depending on what is selected, then in some cases click a button and have the second set of 3 dropdown boxes be filled with the same values. thank you <head> <SCRIPT LANGUAGE="JavaScript" type="text/javascript"> var firstChoice2 = 0; var secondChoice2 = 0;
3
2804
by: happyman992 | last post by:
Hi, I have 2 questions. First, I am building a form with multiple drop down boxes. The options of the second drop down box will depend on what the user chooses on the first, options of the third drop down box depend on what they choose on the second, etc. The values of each option are inside a database which I can query for and put into a php array. I am wondering what is the easiest way to build this. Second, when this form is...
4
2770
by: audreyality | last post by:
I am new to javascript and appreciate any guidance on this issue, so thank you in advance for your advice! Situation: I am working with a form that will send information to a database. I need the following: A drop-down box of options that onChange=... Opens another drop-down box of unique options that onChange=... Displays text dependent on which option you chose. An example:
0
8675
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7729
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6521
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.