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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How Do I Change The Drop Down List So The Option Selected Last Time Is Then The Current One Shown In The Drop Down Box?


I have a drop down list with the town options 'Bury' and 'Ipswich' as
shown below.

When selecting one of the options, its value is passed to variable
$townsearch.

How do I change the drop down list so the option selected last time is
then the current one shown in the drop down box?

<body>

<?php $townsearch = $_get['town']; ?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">

<select size="1" name="town">

<option>ipswich</option>
<option>bury</option>
&nbsp;
</select>&nbsp;

<input type="submit" value="GO" />

</form>




View Complete Forum Thread with Replies

Related Forum Messages:
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:

View Replies !
Populating Drop Down List With Selected Vaue
I have a drop down box and the "selected" value needs to be selected by a dynamic value that gets entered into the database, this is currently how im doing it: PHP Code:

<?php
                if($modify_row[21] == "0") {
                  print "<option value=" "></option>";
                  print "<option value="1">Active</option>";
                  print "<option value="0" selected>In-Active</option>";
                } elseif ($modify_row[21] == "1") {
                  print "<option value=" "></option>";
                  print "<option value="1" selected>Active</option>";

Its fairly straight forward, basically the option that is automatically selected needs to be the one coming from the database $modify_row[21].

View Replies !
Best Way To Show Selected Option In List Box
I need a way so that we can show selected option in list box without using if condition in loop since some times we have lot of options and we have too much if conditions to check.

View Replies !
Selected In A Drop Down
I have two drop down menus. First one is location. When you change location page refreshes and comes with the selected area. So with the refresh,the second drop down changes to the sub-locations of the selected location. For example: Here is my code:

<?php
if ( ! isset($location) ) {
$location="Bodrum";
}
@mysql_connect ( "localhost", "root", "passwd" ) || die ("MySQL'e baglanamadim");
mysql_select_db ( "ceyhun" ) || die ("Veritabanýný seçemedim");
$sorgu=mysql_query("Select *from locations");
$sorgu2=mysql_query("Select *from sublocations where Location='$location'");
?>
........

View Replies !
Drop Down Box With Select Option
I have a couple of drop down boxes which you select the option you want, that value is then stored in the database. If you make a mistake there is an edit option which once clicked shows the form with the information filled in/selected.

However my problem is that when you edit, although the current option which was previously entered into the drop down box is set as the starting value, which is disabled, if you dont change the drop down box the value is deleted rather than held as it hasnt changed. Code:

View Replies !
Preselect Option In Drop Down Box?
i have a page that i use to edit a record problem being one oh the fields in the form is a selection box/ drop down box but when i load the page to edit the record i have to click on the Frame Type again. my question is: How can i get it to automaticaly SELECT the Frame Type? Code:

View Replies !
Drop Down Select Box Which Contains The Option
I have a drop down select box which contains the option other beside this i have a tewxt input called "other_option " that can be filled in if other is selected. On my insert page this is the code i am trying to use to determin what goes into the database Code:

View Replies !
Selected Value In Drop Down Menu
I want the first option ("selected" option) in a drop down menu to be based on the URL a user clicks on. For example, if the user clicks on the link:

layouts.php?submit=true&category=abstract

The first and selected value in the drop down menu should be abstract
Then the rest of the menu will pull from the database.

The code I am using now (below) lists all my categories from my database, but it is not putting the selected value first. How can I get this to work?? Code:

View Replies !
Showing What Was Selected In Drop-down Menu
I'm trying to create a form where the user inputs data, i validate it with php, and if some of the input is missing or invalid then i print out errors with the form filled out with the information they entered/selected previously so they can change/add to it.

The problem I'm having is setting my drop down menus to be selected when the form is returned instead of returning their original state. The menu I have is named A ($A). Here's an example of what I'm doing that isn't working: PHP Code:

View Replies !
Drop Down Boxes Selected Value Against Variable
I have some drop down boxes being populated from a table:

print"<td><select name=project>";
if($project=mysql_fetch_array($pro))
{
do{
print"<option value='$project[proj_name]'>$project[proj_name]";
}
while($project=mysql_fetch_array($pro));
}
else{}

Now my question is, how can i make the value that is selected equal to another variable ie: $myrow[project], upon loading. Any ideas?

View Replies !
SQL Query Selected From A Drop Down Menu
I've got the following query which gets values $search and $furn from a form.

SELECT * FROM properties WHERE description LIKE '%$search%' AND furniture='$furn' ORDER BY id ASC LIMIT $start, $display"

This works almost fine. The only problem is that because $furn value is either 'yes' or 'no', selected from a drop down menu, sometimes when is not selected the query doesn't work. Code:

View Replies !
Dynamically Selecting An Option In A Drop Down Menu
I have a database with a couple of fields that only have a certain number of options. I have a page where a user selects 1 record and updates it. When i query the database and retrieve the data in that particular field,

i want that value to be automatically selected in a drop down menu(since there are a finite number of options and this will prevent the user from putting in bad input which would screw up searching). Code:

View Replies !
Using Variables To Control What Is Selected In An Drop-down Menu?
I have a drop-down menu with the states. I don't necessarily want to have the menu dynamic with a database, but I want to be able to control what is selected using a variable. Code:

<select name=state id=state>
<option value="" selected>--</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
etc...
</select>

View Replies !
Make A PHP Query Select The One That Has Been Selected In A Drop Down Box?
i make a PHP Query select the one that has been selected in a drop down box? Code:

View Replies !
Show Selected Value For Drop-downs In Dynamic Menus
I frequently work with forms where menus are pulled from a database. When a user enters data in the form and then saves it, if it is retrieved later, the form shows the saved data, including the drop-down menus.

The way I normally do this in php is to first retrieve the data for the saved from. Then I create the menus and within the loop of creating the menus I simply add the word "selected" into the results row which equals the saved option on the form. Code:

View Replies !
Drop Down Menu - Every A Value Of It Is Selected To Reload The Page And Submit That Value.
i have a drop down menu and i want every a value of it is selected to reload the page and submit that value. i'm using something like this: HTML Code:

<select name="menu">
<option selected value="1">GENERAL</option>
<?php
while ($cat = mysql_fetch_array($q)) {
$cid = $cat[0];
$cname = $cat[1];
echo "<option value='$cid'>$cname</option>
";
}

echo "</select>";

i tried using <select name="c" size="1" onChange="MM_jumpMenu('parent',this,0)"> but i got confused so i'm looking for an alternative way..

View Replies !
Produce A List Of Tables Currently Within My Database And List Them In A Drop Down Box.
I need to produce a list of tables currently within my database and list them in a drop down box.

View Replies !
PHP Dynamic Drop Down Menus, Page Displays Diff Data Depending On Dropdown Selected.
I currently have two drop down menus the first one with countries and then the second one changes depending on which country is selected to display counties.

This works fine, now what I want to do is have it so when it county is selected it shows all the squash clubs that are in that county below the drop downs. Code:

View Replies !
Drop Down Box Change Event?
Does anyone know if there is a upon change event for drop down boxes in php and how to use it?  I have 2 text boxes that have info in them and when the second one is selected I want to get both values do a sql statment and populate the third box.  So I am guesing to use the event change for the second box to execute the code.

View Replies !
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.

View Replies !
Autopopulating Drop Downs Change To Nothing
I have a form that autopopulates and allows user to make changes where necessary. In this form are some drop down menus (hardcoded on the page). All the selections (50 states for example) are there.

If I select a state it will then post to the database. If I don't select a state and just leave it as the previously selected state (not change the selection already made by a user) it puts a blank in the database. Code:

View Replies !
How Do You Change The Colour Of A Menu Drop Down?
Could somone please help me with changing the colour of a default menu dropdown? The border / dropdown arrow. Code:

View Replies !
Php And Drop Down List
I am coding an email form on a site. A user enters their name and contact email and then selects from a drop down list to which particular email the message should be sent: User1, User2, User3. Then the user types out a message and hits submit. My problem is that I am unsure as to how to grab the selection in the drop down list and pull the selection and place it like this: "$selection@domain.com". Here is the php code:

View Replies !
Drop Down Box To A List Box
i have this drop down box that displays the relevant info from the table that its loading. But the drop down box isn't quite so wise to use if there hundreds of rows. So what i wanted to do was change it to a list box instead ... would any one know how to do that? Code:

View Replies !
Drop-down List
I populate a drop-down list like this:

echo "<select>";
foreach ( $ip_list as $var )
{
echo "<option>";
echo $var;
echo "</option>";
}
echo "</select>";

Is it possible to have the selection in the drop-down list default to a particular value? For example, let's say the complete list of values looks like this:

65.162.31.155
210.213.149.6
68.190.20.83
130.202.234.254
68.122.35.157

When the page is loaded, I want 68.190.20.83 to appear as the selected value in the drop-down list. Can this be done? Any suggestions or examples welcome.

View Replies !
A Drop Down List
im just starting out with PHP and im making a website that hosts some images. Its going great so far but I want to have a drop down that can show my albums. such as:

          <form name="form" id="form">
            <select name="jumpMenu" class="dropdown" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
              <option value="#" selected="selected">Browse</option>
              <option value="#">Ground - Concrete</option>
              <option value="#">Grass</option>
              <option value="#">Metal</option>
              <option value="#">Graffiti</option>
            </select>
          </form>

I want the entrys for this to come from my images folder. For example if i have images/holiday then holiday will come up in the list. Is there anywhere I can get an example of this?

View Replies !
Drop Down List
PHP Code:

<?
         $query = "SELECT `teacher_id`, `teacher_name` FROM teachers ORDER BY `teacher_name`";
         if ($r = mysql_query ($query)) { // Run the query.

    // Retrieve and print every record.
              while ($row = mysql_fetch_array ($r)) {
                      echo "<select name="teacher">";
                    echo "<option value="{$row['teacher_id']}">'".{$row['teacher_name']}."'</option>";
                    echo "</select>";
              }

          }.....

View Replies !
$row In A Drop Down List
I have a query. where I loop through courses, I get the id for each course, pass it to the next page then, I want to query the database again with it, how do I do this.

<select name="course">
<?PHP
$query = "SELECT * FROM courses ORDER BY course_name";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
  echo "<option id='".$row['id']."' >";
  echo $row['course_name'];
  echo ' ['.$row['course_date'].'] ' ; echo ' &pound'; echo $row['course_price']; // echo the number
  echo '</option>';
 }
?>
 </select>

Get the ID then pass it. how do I use it again on another page and another query.

View Replies !
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.

View Replies !
Get The Filenames And Put Them In A Drop Down List.
I want to read a directory for available files and then get the filenames and put them in a drop down list. Whatever the user will select will be the value of the variable $selected. I already found the code to read directories: Code:

View Replies !
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?

View Replies !
2 Drop Down List Using MYSQL
I have a model table with the following fields: MODEL_ID, MAKE_ID, NAME.
And a make table with the following fields:
MAKE_ID, NAME.

The first drop down list (make) to select a make of a car i.e. Chevrolet, Ford. When a make is selected, then all the model for that paticular make appear in the second drop down list.

View Replies !
PHP And MYSQL Drop Down List
I need a script to create a drop down list which has vehicle makes. The vehicle make list should feed a vehicle model list so when I select a make all the models for the make appear in the model list. I have a make table which has MAKE_ID, make NAME and a model table which has MODEL_ID, MAKE_ID and model NAME.

I tried using a script using javascript array but wherever I have a query that pulls the NAME from the database there's always a carriage return after the NAME which messes up the javascript array. I'd rather do it all with PHP if possible. If not please give me one that works and I don't have to spend hours troubleshooting.

View Replies !
Very Simple Drop-down List...
Hi! I'm having a problem with a very simple drop-down list since the
page comes out with no elements in the drop-down but giving no errors.
This is the code:

<form name="year_search_form" method="post" action="results.php">
<select name="select_year" id="select_year">
<?
$query="SELECT * FROM table ORDER BY year";
$result = mysql_query($query) or die ("Error in query: $query. "
..mysql_error());

while ($line = mysql_fetch_array($result)) {
print ("<OPTION value=".$line['year']."></OPTION>"); }
?>
</select>
</form>

View Replies !
Drop Down List From An Array
I want the array to contain a valid year of birth for anyone between the ages of 16 and 80. I'm pretty sure this code is correct.(though it might be a bit sloppy to all you pros) Code:

View Replies !
Drop Down List With Months
I am trying to create a drop down list that has December 2006 as the first option and then goes up month and years till the current month and year (September 2007).

View Replies !
Putting List Into Drop Down
I am working on a directory of businesses which has 8 main categories and each category has several sub-categories. Example: Dining is a Category with Pizza, Fast Food, Chinese, etc. I have the sub-categories brought up in just a list on the left side of the page and when the user clicks on a sub-category it takes them from client_list.php to client_filter.php only showing businesses in that sub-category of the main category. 

So only pizza places listed under dining.  However, I want to change the list to a (form) select box and then have the user click on the sub-category they want and then it takes them to the client_filter.php page to list only those bussinesses in that sub-categorie.  So after that long explanation how do I change my code to do that. Here is my current code:

View Replies !
Insert From An Drop-down List
i have a table in wich i've inserted city's name.then i have an registration form in wich  i want to display an dropdown list with the cities from the table, and if one city is selected to be automaticly added in the second table. how can i do that?

View Replies !
Custom Drop Down List
I am trying to get categories from the database and show them in a drop down list showing root category then their sub category underneath. Code:

View Replies !
Folder List Drop-Down
I am developing a PHP/MySQL project and as part of my initial setup and configuration scripts, the users can select a skin for the application, and a variable value ($skin) is updated to set the current skin, this works ok on it's own, but currently the user must manually type the skin name in a free-text box.

Ideally this needs to be a drop-down option box, and I would like this to be populated by listing the sub-folders within the '/skins' folder, so that it's always up to date. The folder structure looks like this:

/skins
/skins/skin1
/skins/skin2
/skins/skin3

How can I use PHP to generate a list of the current sub-directories in 'skins' and populate the drop-down list?

View Replies !
How Do You Pass A Value From A Drop Down List?
I am completely new to this. I don't understand how to receive a value from a drop down list <select> menu. I have read many tutorials and none of them explain the process of receiving the sent data.

View Replies !
Drop Down List Of Months
I am trying to create a drop down list with 12 months as the contents. I need to be able to determine what the latest month is and then put the 11 months before into it (in the correct order). For example, it is September 2007 obviously at the moment, so that will need to be the last and latest month in the list. The other 11 will be in reverse order going back to August 2006.

View Replies !
Populating A Drop Down List With Php
I am trying to get a drop down list to populate vbia php. What I have a is a script that allows a airline/user to enter airfare and price for tickets. It dumps them into a database and then allows the user to view/delete/add.

I want the user to be able to edit the airfare. I have a drop down list that is set as a variable $ticket_from, $ticket_to. The list contains around 400 cities. When the user clicks 'edit' I have the price population but no the drop down list. How do you go about something like that? I have this right now: Code:

View Replies !
Drop Down List Menu.
How do I make one item required on my "drop down" list menu? E.g., let's say that I want one state to be selected, how do I make this possible with PHP? My PHP skill is amature, but I do understand most.

View Replies !
Drop Down List Processing
I created a simple form in drop down list for USPS and FedEx. How do you process the drop down list?. If I select FedEx option, how do you retrieve it soI can use it in a query to find the Shipping Company store in my database. PHP Code:

<?php
   include ("header.php");
   print "Select shipping choice;
   
?>


<form action = "confirm.php" method = "post">                       
   <table border = 0>
    
      
       <tr>
      <td>Shipping choice </td>
         <select name="Shipper">

View Replies !
Dynamic Drop Down Box List - Php
I have two dropdown boxes. Two boxes have values from two different tables. They dont have any common field to relate with. I would like to display the values based on selecting the first combo box value. If i select first combo box value, then automaticlly the second drop down box value should be changed.

Code: ....

View Replies !
PHP To Display Drop Down List
I'd like to have 3 drop down lists connected.

Division
Department and
Section

Where the options of Department are dependent on what is selected in Division and the options of Section are dependent on what is selected in Department. So far, all the examples I've found have been using JavaScript. Can I do this in PHP as I have no knowledge of JavaScript at all.

View Replies !
Retaining Drop Down List Box Value
I currently have my drop down lists populated by a table from the sql database how can i retain the selected option once the form has been submitted. I know how to do this with textfields but cant figure out the dropdown lists because its being populated by a db. My code is as follows.

$cat = "<option value=>all</option>";
$cat .= "<option value=$row[id] $catselected>$row[name]</option>";

echo "<tr>
";
echo "<td class="classadd1"><div class="maininputleft">category</div></td>
";
echo "<td class="classadd2">
";
echo "<select name="in[catid]" style="width:200px;" onchange="changecat(this.options[this.selectedIndex].value)">$cat</select>";
echo "</td></tr>
";

View Replies !
Problem W/ Drop Down List
This current problem of mine is driving me nuts, there has to a solution. I'm farily new to PHP and have a couple questions which hopefully can be answered. I have two files, contact.php contains a form, with a drop down list.

When the user hits the submit button, they are directed toward tutorialcontact_result.php which catches any errors. If there is an error, on this page I provide a link back to contact.php. My first problem is: I'm trying to validate a drop down list using a regular expression as shown below: Code:

View Replies !
How To Add URL To Options In Drop Down List
I am have a drop down list, whose options are read in dynamically from a table in a MySQL database. one of the items being read in is an URL. I am unable to display this URL in the drop down list. The following is the code snippet I am using: Code:

View Replies !
Database Into A Drop Down List
I'm trying to pull data from my database and display this data in a drop down list. I have 3 drop down menus, when a sourcre is selected in the first menu. only the destinations available from that source should be displayed in the 2nd drop down and then the destinations of the next selection displayed in the 3rd drop down.

View Replies !
Search Via Drop Down List
How would I go about writing code so that a user could search by a drop down list, clicking on the date they want and then the page shows the record with date,availability and price from the database?

View Replies !

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