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
Sponsored Links:
Related Messages:
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.
View Replies !
View Related
Get The Option Selected Once I Have Submitted The Form.
I am using the following code to loop 12 months backwards from the current month in a drop down list - using the get method. I'm having difficulties trying to get the option selected once I have submitted the form. For example, I am using this to filter months, so once a month has been selected and submitted, the first option in my drop down list is displayed and not the one that was selected and submitted. So basically, I need to be able to select a month > hit submit and when the form returns, have the drop down list show me the selected item. Code:
View Replies !
View Related
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?
View Replies !
View Related
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:
View Replies !
View Related
Remember Selected
How does a script remember selected qty when the user needs to edit an order form. echo"<select name ='blar'>"; for($num;$num<$num2;$num++) { echo"<option value = '$num'"; ........................... // here needs to be selected = 'selected' at the correct place?? echo">$num</option>";....
View Replies !
View Related
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:
View Replies !
View Related
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?
View Replies !
View Related
Outputting Selected Option
Given a dropdown form how can I output the selected option when the submit button is pressed. Box: [red ] [submit] [green ] [blue ] [orange] so the user selects an option from the dropdown menu, which is highlited then they press submit, I want to display red, green, blue or orange, whatever was submitted.
View Replies !
View Related
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?
View Replies !
View Related
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>
View Replies !
View Related
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:
View Replies !
View Related
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:
View Replies !
View Related
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?
View Replies !
View Related
Seting The Selected Option Dynamically
I have a dir listing appearing in a list field of a form as showwn below PHP Code: <?php $current_dir = 'images/upload/' $dir = opendir($current_dir); $list = "<select name="listbox">"; while ($file = readdir($dir)) { $list .= "<option value="$file">$file</option>"; } $list .= "</select>"; { echo $list; } closedir($dir); ?>
View Replies !
View Related
Print To Screen The Currently Selected Option
I then need to print to screen the currently selected option, but on the same page- no going to a new page etc. PHP Code: $host = "localhost"; $user = "root"; $password = "!"; $database = "rio_test"; $connection = mysql_connect($host,$user,$password) or die ("Couldn't connect to server."); $db = mysql_select_db($database, $connection) or die ("Couldn't select database."); echo "<select name="ticketName" id="ticketName">"; echo "<option>IPTIS Ticket Name</option>"; $query = "SELECT * FROM new_calculator";
View Replies !
View Related
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.
View Replies !
View Related
Remember Form Settings W/cookies
I have a sort script that i use to sort the results on a page. And the form sets a cookie and goes from there. It work all great. But the problem that i need to fix is remember the settings in the form. <form action ="list.php" method = "post"> View by: <select name="view"> <option value="title">Name</option> <option value="views">Popular</option> <option value="date">Newest</option> </select> Order by: <select name="order"> <option value="DESC">Descending</option> <option value="ASC">Ascending</option> </select><br /><br /> Per page: <select name="per"> <option value="1">1</option> <option value="2">2</option> <option value="5">5</option> </select> <input type="submit" name="sort" value=" Sort " /> </form> Now when you submit this form it will set a cookie with your "view", "order", and "per" selection. What i want it to do is after you set that cookie and come back to this form to have them settings remembered in the form. Basicly i guess add the selected="selected" to the option script in the form.
View Replies !
View Related
Mail Form - Get The Form To Send The Selected Values
I've basically created a simple email form in html and used php scripting to send the form to my email. now I thought I should inlcude more options in this form to filter out some data I'm collecting in my emails. So i've now included some radio buttons and drop down list/menu. I've entered all the values and labels, the main question is how do I get the form to send the selected values along with the usual info i.e. name, address, email etc to my email? PHP Code: <? $mailto = 'john@something.co.uk' ; $subject = "Feedback Form" ; $formurl = "http://www.something.co.uk/contact.html" ; $errorurl = "http://www.something.co.uk/error.html" ; $thankyouurl = "http://www.something.co.uk/thanks.html" ; $uself = 0; .............................
View Replies !
View Related
Option In Form
I have this HTML code HTML Code: <form method="POST" action="action.php"> <input type="submit" value="Address" name="B2" style="font-family: Verdana; font-size: 8pt; color: #FFFFFF; border: 1px solid #000000; background-color: #000000"> <input type="submit" value="Phone" name="B2" style="font-family: Verdana; font-size: 8pt; color: #FFFFFF; border: 1px solid #000000; background-color: #000000"> </form> in action.php i want a code to run depending on which optoin was clicked ie: B! or B2, how can this be done?
View Replies !
View Related
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:
View Replies !
View Related
Form Auto Select Option
I have a website that has a contact form with a dropdown list of names. I would like to code it so that when a user selects a person's name from another page, that when it brings them to the contact form, that name is automatically selected in the dropdown list.
View Replies !
View Related
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:
View Replies !
View Related
Form That Allows The User To Select A Sorting Option.
I have a form that allows the user to select a sorting option. One of the options is a day of the week. (The table is a list of courses and their times/locations/days.) I can get the results to sort by user option, but how do I make the days sort chronological rather than alpha if this is the option selected? This is my code: $query = "SELECT * FROM classes ORDER BY '$schedule'"; The user selects which way to display the data through the $schedule variable.
View Replies !
View Related
"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?
View Replies !
View Related
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:
View Replies !
View Related
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>
View Replies !
View Related
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?
View Replies !
View Related
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.
View Replies !
View Related
Remember On Login
my script www.myprofilepic.com runnin dolhpin 5.4 was wondering how i cud add the remember me feature on the login box,so when people close page and open it,they still remain logged in ':thumbsup:'
View Replies !
View Related
Remember A Member
I made a member system it works great but i want to make a posting area for my members. At the mo i just have a simple forum script so am adding it to my member system i have the auth working so it only lets members post. I just don't know how to allow my members to edit or delete a post. i know how to delete posts and edit them if you know what i mean it's just allowing the person who submits the post to edit or delete it? it would be really great if someone could show me as well as tell me how this could be done.
View Replies !
View Related
Remember User
I have a script where people can vote for a website, but I ony want people to vote once. I was using ip addresses to track that, but I found that ip addresses can change on a computer. Is there a better way to identify a person's computer without using cookies.
View Replies !
View Related
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; } }
View Replies !
View Related
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();
View Replies !
View Related
|