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




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 Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Make Selected Option Stay Selected In A Combo After Submit
I have 3 comboboxes, one for the day, other for the month and another one for the year. Every time i select a value for the three of them and press the "Submit" button, they reset to the default option. Anyway this can be solved?

PHP And A Pre-selected Option In A Form
I've got a little text editor thing on my site, and to open a file, you input the file name and choose the folder from a drop-down list and click the Open button. The default filename is "index" and that file keeps track of all the files contained in that folder. It works okay. What's annoying is that regardless of what folder you're messing around in, the drop down list always goes back to showing the default folder name as the page is reloaded. I want it to be preselected to the folder it's in.

It seems simple enough--the folder you're in is $_GET['dir']. But I've read some HTML form how-tos, and I can only see that you can preselect using the tabindex="" or selected attribute.

Setting Selected Option Using PHP
I have a drop down list which I want to be set to what was selected when the form is submitted. As the form is processed by the same page, it returns to the preset default. How would I go about making this selection box set the option selected on the next page?

Get The Info Depending On The Selected Option
I have a page that is intendend to update a table field on DB i have a drop down menu wich displays all the position fields available on db and a text area where i will insert the new data.

now the problem: I'm using the query SELECT * FROM table WHERE position = $position
the $position is the choosen option from the drop down menu. then have echo "<textarea>$functions</textarea>" where it will show to me the present data available on DB after all this, i have another query UPDATE table SET functions = $functions WHERE position = $position

All is ok and working except the fact that he doesn't displays $functions
when selecting a option from the drop down menu?

Set The Selected Text For Option Box Of A Menu..
Having major issues with this simple task, and I cant work out why its
not doing as it should/expected.

Basically, ive got a drop down box with the added bit of php:

<select name="title" id="title">
<?php
if($_SESSION['title'] != "") {
echo '<option value="'. $_SESSION['title'] .'"
selected="selected"></option>'
}
else {
echo "<option value="" selected></option>";
}
?>

<option>Mr</option>
<option>Mrs</option>
<option>Miss</option>
<option>Ms</option>
<option>Dr</option>
</select>

Basically, if the user submits a form, the title is stored in the
session, this works fine, and then when returned to the page, the value
should be filled in.

Yet, when they return to the page, there value they selected is not
shown in this box, instead, theres just a gap. The source seems
correct, and this is whats shown:

<select name="title" id="title">
<option value="Mr" selected="selected"></option>

Keeping Select Option Value Selected
I'm trying to learn how to keep the value "selected" once a form is set to read the values and then f-write them (all within a loop). The part that's giving me a problem is the part which would return the value of the form as "selected". PHP Code:

Multiple Select Box With Selected Option ...
first of all I have three tables (tournament_game, umpire_game, umpires). Updating tournament_game umpires, each game may have from two to four umpires, and those umpires can work from one to n number of games, that's why I'm using connection table umpire_game. I'd like to get selected multiple select box of umpires in game, it could be two to four options, with all umpires listed as options example:

<select name=umpire_game[] size=10 multiple>
<option value=$umpire_id>$umpire_name</option>
<option value=$umpire_id selected>$umpire_name</option>
<option value=$umpire_id selected>$umpire_name</option>
<option value=$umpire_id>$umpire_name</option>
<option value=$umpire_id selected>$umpire_name</option>
<option value=$umpire_id selected>$umpire_name</option>

PHP Code:

How To Get Form To Remember Selected Option?
I am now trying to make a form remember which color (a select list) they selected before pressing any of the submit buttons. I entered this code into the form:

<select name="color">
<option value="red">red</option>
<option value="blue">blue</option>
</select>

The submit is a GET type. For example, if the user selects blue and then clicks on either one of the "submit" buttons, I want the form to remember/show the blue option. Right now the select list always goes back to red, the first choice. I tried doing a <?php echo $red; ?> and <?php echo $blue; ?> for the option value, but this does not work since the select list needs a value.

Select Option Stays Selected
I have a normal drop down menu:

<select name="status" class="db_list_text">
                    <option value="All" selected="selected">All</option>
                    <option value="True">Active</option>
                    <option value="False">Inactive</option>
                  </select>
The idea for this is for the user to select either true or false and then to click submit to find data that matches either one. The coding is in the same page so the form basically just reloads the page and grabbes whatever info is requested. How can I with PHP, make it that the dropdown stays on the selected option when the page is reloaded?

Option Selected Multiple Rows Logic
I am having problem getting the logic to work to get a multiple option box to get populated from the database and select the ones which are already in the database. Here is my code: 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:

PHP/MySQL: Query Based On Selected Form Option
Using PHP and MySQL. Trying to put a list of categories into a drop down
select option of a form like:

<form name="form" action="<? print $_SERVER['PHP_SELF']?>" method="get">
<select name="subject">
<option value=""></option>
<option value="field1">Field 1</option>
<option value="field2">Field 2</option>
</select>

<input type="submit" name="Submit" />
</form>

Then I want to process it so the MySQL query gets done depending on what
was selected. I came up with this:

//connect to database
mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbase") or die("Unable to select database");

// Build SQL Query
if (isset($_GET['subject']))
{
switch($_GET['subject'])
{
case 'field1':
$query = "select * from tips where category = 'field1'";
break;
case 'field2':
$query = "select * from tips where text like 'field2' ";
break;
default:
echo 'No subject found'
}
}

$results=mysql_query($query);
$numrows=mysql_num_rows($results);

etc etc etc

But that switch doesn't seem to work. Anyone have a suggestion as to how
I can code this to do the MySQL query based on the subject?

Select Pictures And Show Selected
I need to make a webpage (php) where users can select some
excercises(with picture) out of 40, and then display a page with only
the selected excercises (with their picture) that you can print.

Php Selecting Problem - Show Selected Value When Going Back
In my pages i have a select list. For example the visitor has
5 options (including the default :D ). So here they are: the default ->
location; first option -> USA; second ->FR ; third -> IT; forth->SW

Let's call this script script1.php
In this script i want to check if there are no errors, i mean i want to see if
the visitor choose a valid location (USA, FR, IT or SW ) and not the default
one.

Now if the user select didn't select a location (equivalent to selected the
default value) the same script after is executed will will echo an error
message. If the user choose a valid location the the action will be script2.php which will echo the message: "You live in $location."

Now there is one more thing to ask. If the visitor goes back from script2.php
to script1.php i want to apper in the location field the selected option and not the default one. How is this possible?

Multiple Selected="selected" In A List.
I have a database with 1 to many and the many is a list with multiple
selects in a list. When I click on a master record I have as part of
my form the select statement for the multiple choice list. I want the
list to highlight the multiple chosen values. here is part of the
code.

$dresscat = specdresscat($dresstypeid); //this is the query to get the
values in the detail table
$drcatrow = pg_fetch_array($dresscat);// the array for the detail
table.
<select name="stages[]" multiple="multiple">
<?php
$allstages = allstages(); // this is a function to query my database
to get the value for the list.
while ($allstagerows=pg_fetch_array($allstages)) {
$eachstage= $allstagerows["stageid"];
$specstage= $drcatrow["stageid"]; // this is the point I need help
if ($specstage == $eachstage){ ?>
<option value=<?php echo $eachstage;?> selected="selected"><?php echo
allstagerows["stage"]?></option>
<?php }else{ ?>
<option value=<?php echo $eachstage;?>><?php echo
$allstagerows["stage"]?></option>
<?php
}
}
?>
</select>

Editable Option List
I fill a list of option from a mysql table

$resultprod = mysql_query ("describe my_table");
while($row = mysql_fetcharray($resultprod)) {
echo ('<option value="' . $row['Field'] . '">' . $row['Field'] .
'</option>');
}
echo "</select>";
}

but I would also like the user to be able to add itīs own value if the
value he/she want to enter is not in the mysql table. how can I do
that?

Dynamic Form Option List
I want to create a dynamic drop down option list in a form, but I just can't wrap my head around this.

Both of the below scripts work as intended, but how do I make the mySql query results work with my existing script?  Yes, I know I must replace the "$options = array" part in the top piece of code, but I need a little more guidance than that. Code:

Html Pre-selected List Box Scrolled
Is it possible to have a list box with a pre-selected value automatically scrolled to that value when the form is loaded? i.e. if the size of the list box is 3, and the 4th value is pre-selected, I want the list box to appear starting at the 4th value in the form.

How Do You Do Selected In A Multi-value List Box In A Form?
I am populating a list box from a dictionary table and then picking
muliple values to insert into a detail table. How do I get the list box
to have multiple selections highlighted when I pick one of the master
items?

List All But Echo In Checkbox Only Selected
There is a 3 table: I want to list all the product groups but to be checked in checkbox only what choose the user.

If from outside (choos.php?tt_reg_id=1) user is nr 1 then in listed checkboxes need to be checked only those checkboxes what the user nr 1 choose / but listed the all product groups. Code:

Session Variable To Pass The Id Selected From A List?
I have a list which the user can select from in order to go to another page with details of the selection. I currently have the id of the selection being passed on the link as follows: PHP Code:

Transferring The Selected Record From The List Box To Textbox
Breifly, I've 3 list boxes.Select a record from the first one, click a button, the second list box is filled and select a record now and then click a button, the third list box is filled.Now, select the record, the selected record has to be shown in the text box.But, I also want to show one more field related to this one in another text box.How can i do??

well, the first list box shows the topic names, 2nd one the sub-topic names and the third one the article names. Now, when i select the article name, the article name and the article content has to be shown in the text boxes.

If its just article name, i know how to do it by java-script but i also need article content to be shown. Could somebody please help me how should i modify my code and where should i insert the text boxes?? Also, one more question, If i make any changes to the data in the text boxes, i would like to update.How can i do that?? PHP Code:

Combo/list Box Showing Values Selected
I have a combo box being populated dynamically through php using a mysql database, and everything works fine.

My question is: How would i make it keep the values selected, once the user hits the submit button? For example, let's say i have a combo box with the values 1 2 3 4 5 in it. The user selects &#393;' and hits the submit button (which posts to the same page). At that point, i'd like the combo box to still have &#393;' selected, instead of resetting itself.

Show List Box Current Value
I'm trying to populate a list box on an edit form from a mysql table, and have it default to the current value. I've actually found a number of examples in this forum, but I can't get any of them to work. I'm new to php and mysql, so I'm probably missing something simple.

The table I'm editing is called "Members".
The field that this box will edit is "sgifts1".
The values are stored in a table called "giftlist" in the "gift" field.

Here's what I have so far: PHP Code:

Show List Of Users Online
How can i list the users logged into the system?

Maybe save the list of session id in application attribute?

Php Sending Mails To Mailing List Show Strange Headers
i need to send a mail to one mailing list address.when i sent to this the from address comes as newsletter-request@abc.com; on behalf of; ABC[abc@abc.com]
where newsletter@abc.com is the mailing list id abc@abc.com is the moderator id

when i change the to address to any other email address other than this mailing list, the from field works fine. i have given the mailing list, in the Bcc header.

Select <option> </option>
I have this script in a form, it is trying to send a selection from the from to the next page. But the proble is that if the selection has a space in it, it only sends the first work to the next page. Code:

Code To Show Slide Show In PHP
Can anyone guide me as to how can i display a slideshow of all the images present in an album and if possible the code.

Show Table Only If There Is Data To Show?
I have a table that shows specific data (via a while loop)

however, when you first log in as a new user, you see the table column headers but there is obviously no data, and it looks a bit unsightly.

How could i take this code:

List Contents Of A Folder, Make List Of Links
Does anyone know how I can write a script that:

- reads in all the files in a particular directory
- displays the file names in a html list and makes a link of them:
<ul>
<li><a href="filelocation1">filename 1</li>
<li><a href="filelocation2">filename 1</li>
<li><a href="filelocation3">filename 1</li>
</ul>

etc.?

So basically it creates a list of links with the contents in that directory,
so you can download them from there.

Get List Of Messages From One Table, Message List Indicator From
I have two tables. One has a list of messages left by users using fields named mbxno for the mailbox and msgno for the message number. I have another table that has mailbox settings for each user that contains a field named "messagelist" to indicate if they want to be included on the message list or not.

What I'm trying to create is a list of the most-recent messages with a lookup on the users table to indicate whether a message in the list should be included in the message list based on the user's mailbox settings.

SELECT messages.msgno, messages.mbxno, users.messagelist FROM messages, users WHERE (users.messagelist = &#391;') ORDER BY msgno DESC LIMIT 100

What I'm getting, though is a list that looks like this:

mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1

I think what's happening is that I'm using the wrong type of join and more rows are being created than necessary.

If I add "DISTINCT" to the query, I get a list of the most-recent messages as I expect, but the "messsagelist" value is sometimes wrong (again, probably because the data is getting jumbled). For example, the messagelist value for the second row (2214) should be 0, not 1.

mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 2214 msgno: 0412141622 msglist: 1
mbxno: 2189 msgno: 0412141408 msglist: 1
mbxno: 0000 msgno: 0412141213 msglist: 1
mbxno: 0003 msgno: 0412141213 msglist: 1
mbxno: 2265 msgno: 0412132029 msglist: 1
mbxno: 0000 msgno: 0412131950 msglist: 1

How should I be doing this? If nothing else, what kind of join will work with a long list compared to a value from a short list?

Populating A List Box Or A Dropdown List Using Php And Odbc
I need to populate a list box and/or a dropdown list on a form. I have all
the bits and pieces together, all bar the code which takes the result of a
query and creates a list box.

Mailing List Manager, Send To List
I'm looking for a mailing list script (php) that has a function to let
users to reach out to all recipient on the list by simple send the
email to a specific maillist- address.

Mailman has this functionn but as a just got a webserver account I
can't use mailman nor install it.

Option Value
I have a drop down menu and I want to insert the selection from the drop down menu into the database. How would I go about this?

Add Option Modifiers
I am working on trying to create an admin for a product catalog, the only problem i am having involves product modifiers such as the ability to add size and color to the product that can also increase the cost of the product.

I was wondering if anyone would know a really good way of going around to do this, the only way I can think of is having a product option table that would hold the value of the modifier plus the cost plus the product id that this references too plus its own special id.

PHP GTK Option Questions
Before I invest more time in researching and testing I am curious if anyone knows for certain if a PHP_GTK application running on a Windows machine can communicate and interface with a remote database SECURELY?

My plan involves creating a support system which would be a standalone application on a Windows Workstation. This application would query data from a remote database SECURLY and then support personal would be able to modify, edit, etc. data from the PHP_GTK application which would in turn update data in the remote database, again securely.

Can a PHP_GTK application support this, security being the biggest concern?

Readdir & Option Value
more or less that is my problem:

i'm making HTML <select><option> statement:

if ($dir = @opendir("/the/directory)) {
while($file = readdir($dir)) {

echo '<option value="'.$file.'">'.$file;
}
}

the number of options depends of number of files in directory.

When user chooses one of this files(he chooses an option) i want to know
what option he choosen.

Option Button ?
I want to create a form with 3 groups of 2 options buttons (radio buttons in Dreamweaver). Can someone helps me in sending links to PHP Reference ? Example:

a > 0
Option(Yes) Option(No)

b > 0
Option(Yes) Option(No)

c > 0
Option(Yes) Option(No)

Submit Button Action of the submit button: If option_a_yes is checked (...) then open html.

Option Values
From my experimentation there seems to be a difference when using values from an option value as apposed to an value by a check box etc. I can quite easily input data from a check box selection, but not an option value. Code:

Remember Me Option
Any ideas on how to create a remember me option in a login box..?

Pagination Option
Below (A) is a portion of my pagination code where I specify the limit. What I'd like to do is add a select function (B) that will allow users to specify the limit. On change of select option, it should refresh with the new limit: Code:

Select Option
How do i click on an option and  then automatically sort a mysql query by that value? I can get a set of option to appear and can do a query but not combine them? Code:

Option Selection
I am making a Option Box (Drop down bar) for Gender, (Male,Female) and I want when they Select there Gener, and then hit submit, it Writes to to a Database.

i have it set it up so far that it goes to another page to INSERT it into the Databse.

<select> Option
I know PHP is a server-side language, so it's not client-sided. What I want to do is have a <select> dropdown with options and I want the page to refresh itself and display some information on that option. The problem is that since PHP isn't client-sided, I don't know how to get the value of the selected option and display the relevant info on that option. Any ideas on how to do this with PHP?

Option Value Remember
When a user clicks on a car the option box selects what car has been choosed, after filling the form in and if he has forgotten to type some info, the script echos what did he forget, and the prob is, that the option value disappears.
How can i save the value or post it over? Code:

No Database Selected
what I've got it a simple system that includes pages the reference to which are in a database. This bit worked a treat. until i tried to put something that did some work in one of the included pages. PHP Code:

Selected Box Action
how to set the respond to action when user choose an option inside a <select></select> box? eg. when user select an option in the <select> box then php search for data inside mysql and then display the required data on the <input type=text>.

Php Dropdown - Selected?
i'm using this to pull information from a database and display it in a dropdown list. The problem is I am using the name code when I goto the "Update" page, but i'm not sure how to add the "selected" field, that way what ever I saved in the database will load.

Example: I goto add and it add's the "id" of 7 to the field, when I load the page again it auto's back to 1 instead of clicking in-to 7 as thats whats already there... = ) Code:


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