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.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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.
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?
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:
Remember Selected Value DropDown
I am attempting to have a drop down menu that displays url from 1 table called links the same table also contains a name for the url. i.e. google.com = name and http://www.google.com = url The value of just the url from links is stored in a separate table called users in a field named search after form is submitted by user. Everything Posts correctly except when go back to edit the record and submit the form the drop down box does not retain the value of what had been previously selected although it is the correct record until form is updated when whatever value is currently in the drop down list will update the record. I know the code is doing exactly what it is told to do, because I have no functionality in it to recall the value from the field search in the users table. I don't know if it is something I would have to add to the array or option value. I can get it to work if it is all hard coded, but I am attempting not to do this. I am pretty new to php mysql and any help is greatly appreciated. This is the code I am working with that came mostly from a tutorial. PHP Code:
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:
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?
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.
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 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:
Remember Form Values
I have a form, and I'm using PHP to make sure the users filled in certain fields. If they haven't filled in a field, they are brought back to the form after submitting (using header location) and asked to fill it in. However, when they go back, the form values are all gone. How can I keep the form values there? I know i've seen it done, but I can't remember where.
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:
Dynamic Form Option Diapearing On Submit
when i submit one option field after inserting a option value and an amount the previous one i had done disappears causing me lose all the information that i had typed in and i was wondering how i could keep the information alive as well as keep the newly created form fields from diapearing, PHP Code:
Setting Variables For Only The Selected Items In Form
when a form has a question where the response can be one or more selections either from a series of chech box inputs or a selection list, how would i set into variables only the responses that are checked or selected so that only these values are available for exporting to a mySQL database?
Attach JPG File" Option In An Email Form?
How do I programm "attach JPG file" option in an E-mail form? The file may not be bigger than 2 megabytes and must be sent to the email adress wich is programmed in my existing e-mail script. In return for a good solution I will give you something nice in return.
"Remember" The Values On A Form
how to get your code to remember what the user typed in after they click back when using sessions. Right now, if the user fills out the form and submits it to find an error, then when they click back all the fields are empty because I am using sessions. Does anyone know of the line of code or the tutorial that will refill the fields with the values?
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:
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>
Remember Input Value
I have a form, after users submit it, if they leave the required fields blank, I need to let them go back to the page and fill those fields. How can I remember the values the users already filled so they don't need to fill the same fields again? Is there any other ways to do this except using cookie? Is there any 'forward' or 'redirect' function can do this?
Trying To Remember A Function's Name
I am drawing a total blank on this... I'm sure that I've seen it in javascript or PHP... I'm looking for a function that takes a variable (such as an array) and reduces it to a string which can be reconstituted. I remember that it does slightly more work than needed because all the types were specifically indicated even when they were self evident, but I can't remember the function's name. There is some unencoding function to go in reverse.
Login Page: Remember ME
This is my 1st posting to this group. Can any1 help me with the "Remember Me" which is there in a login form. Im pasting the code below. Im not able to set a cookie.. <?php // saving script session_start(); displayLogin(); // connect to the server $conn= mysql_connect( 'localhost', 'csci242', 'spring2006' ) or die( "Error! Could not connect to database: " . mysql_error() ); // select the database mysql_select_db( 'blogtagz' ) or die( "Error! Could not select the database: " . mysql_error() ); // get the variables from the URL request string $uname = $_POST['uname']; $password = base64_encode($_POST['password']); $reme=$_POST['rememberme']; /** * checkLogin - Checks if the user has already previously * logged in, and a session with the user has already been * established. Also checks to see if user has been remembered. * If so, the database is queried to make sure of the user's * authenticity. Returns true if the user has logged in. */ function checkLogin(){ /* Check if user has been remembered */ if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){ $_SESSION['uname'] = $_COOKIE['cookname']; $_SESSION['password'] = $_COOKIE['cookpass']; } /* Username and password have been set */ if(isset($_SESSION['uname']) && isset($_SESSION['password'])){ //if(confirmUser($_SESSION['uname'], $_SESSION['password']) == 0){ /* Confirm that username and password are valid */ if(confirmUser($_SESSION['uname'], $_SESSION['password']) != 0){ /* Variables are incorrect, user not logged in */ unset($_SESSION['uname']); unset($_SESSION['password']); return false; } return true; } /* User not logged in */ else{ return false; } }
Session Remember Things It Should NOT....
I use sessions to store information in $_SESSION. However, variables that are not in $_SESSION that I define myself is also remember between pages in the same session. What gives? Is $error_msg a some kind of global variable? So, I might have two pages, let say page1.php and page2.php. They both use the variable $error_msg and session_start();
Remember Drop Down Box Selection
Is there a better way to do it than i currently am using? Simply echos the value in the selected option that will otherwise be blank, so this makes it impossible for the user to select no input. Code:
Remember Array Contents
I have the following code, that inserts the ID value of a link into an array, upon the link being clicked. See example link below: www.somthing.co.uk/functions.php?id=23 How do I get the array to remember its contents, so if the browsers back button is used, and another link is clicked, this link should append/add it's id to whats already inside the array? What do I need to change in the following code in order for the array to remember its contents: <?php $array[] = $id; print_r($array); ?>
PEAR::Auth 'REMEMBER ME' Feature
I use PEAR::Auth module to login my users. I noticed the lack of the 'remember me' feature (and the method 'setExpire' isn't enough). So I wonder HOW can I extend this package and provide the 'remember me' feature.
Looped Rows In Table Add & Remember Values
I'm trying to get this app to work. It's supossed to: 1. create rows dynamically through a loop (done) 2. remember the user-entered-values while the form posts to itself 3. provide a total (addition) of all 4 rows. (kinda tricky since the rows are looped). PHP Code:
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:
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?
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:
Imap_mail_move Or Imap_mail_copy Option
To develoment. I use imap function by UW imap4 at PHP. imap_mail_move function can have option CP_UID for coping UID by PHP manual. but UID does not copy. I don't know why it is not. I hope to detect the reason. PHP 4.3.x UW IMAP4
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?
|