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 Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Selected List Item Value
I know that the value for each element of my form is available through $_POST 'element_name'] but this doesn't work for lists. Can anyone tell me how I refer to the item selected in a list (combo box)?
View Replies !
View Related
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.
View Replies !
View Related
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:
View Replies !
View Related
User Selected Order Of List
My experience in php and mysql is just copying and pasting freebie scripts- very limited. I'm wanting to create or better yet find another freebie script which will in my real estate site on the page with a table listing properties with headings such as date/ type/beds/baths/price etc. users be able to click on a heading which will then list the properties according to the selected heading, so if they choose 'type', the page will refresh and show all houses or land or apartments according to type grouped together and so on. First I think I need to have a link on the heading buttons to activate a php script which will send info to mysql database and if the database is configured right through the admin area it will respond accordingly. But what php script? How complicated could it be?
View Replies !
View Related
Dropdown List Selected By Default?
Does any one know how to have an item in the dropdown list selected by default? $city_field = HTML_QuickForm::createElement('autocomplete', 'city', 'City', $cities); $cities is an array of city names and I would like, say 'Los Angeles' selected by default.
View Replies !
View Related
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:
View Replies !
View Related
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 Ɖ' and hits the submit button (which posts to the same page). At that point, i'd like the combo box to still have Ɖ' selected, instead of resetting itself.
View Replies !
View Related
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 !
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
Selected Item To Use For Multiple Variables
I've got a list of 'items' and those 'items' have unique 'categories'. I have 1 table for 'categories' that contains a list of category_ids and their 'category_names'. The other table is the 'item' list. And here's where I'm running into difficulty, I'd like to have the 'item' table contain the category_id from my 'categories' table as a Foreign Key and that category_id's 'category_name' in a 'category' field. I'm getting the Foreign Key, but I can't seem to grab the 'category_name' and assign it to my $category variable in the 'item' table. I've got a page to insert items and a page to update these items. I was working with the update first. And I'm able to grab the list of categories and select the correct one, but I'm not seeing where to assign the category_name to the $category variable. Here's dropdown list: Code:
View Replies !
View Related
Sending Mail To Multiple Users (which Can Be Selected By The Sender)
I'm looking for a script to email a contact form to multiple emailadresses but that the user can choose to which people the email is being send, like for example: the user only sees a few names with checkboxes and by selecting a few of those checkboxes (with only the nicknames of the recipient(s) viewable for the user NOT the emailadress) they can select to which people they would like to send that Email.
View Replies !
View Related
Selected Value
Trying to get the below to have the SELECTED value chosen but it is not working. What am I doing wrong? while ( $buyerline= mysql_fetch_array($getresult, MYSQL_ASSOC)) { print "<option value='$buyerline[id]'".($buyerline[id]=='$buyer'?' SELECTED':'').">$buyerline[buyer]</option> "; } print '</select>'
View Replies !
View Related
$selected
I'm trying to generate a select box through php. the problem comes when I try to dynamically add in the 'selected' attribute to one of the options. My script is basically the following: Code: foreach($values as $key => $value) { if ($key == $checkVar) { $selected = ' SELECTED' } else { $selected = '' } $options .= '<option value="'.$key.'"'.$selected.'>'.$value.'</option>' } print '<select>'.$options.'</select>'
View Replies !
View Related
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>.
View Replies !
View Related
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:
View Replies !
View Related
Know Out Of All Checkboxes How Many R Selected And Which Are They?
i have a checkbox array of some unknown size.its a dynamic array created. i want to know out of all checkboxes how many r selected and which are they? and then insert the data in the table based on that. i hav written the code as follows:- <? $no=0; $friendname= $_POST['friendname']; $storecount=$_POST['storeid']; while($no<$storecount) { if($friendname[$no]) { $sql = "INSERT INTO groupfriends (groupid, username) VALUES ('$stid[$no]', '$friendname[$no]')"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); } $no=$no+1; } ?> i dont think this will work.it will add all the checkoxes data to the table. i want to insert only of those which r selected.
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
Selected Combo Box
i have the following code and i am having problems with setting the combox to select the value that is stored in the database. i am hoping that the combo box selects the value and the value from the database is stored in $title PHP Code: <?php function displayedit($id,$title,$fn,$ln,$instit,$depart,$email,$url,$room,$phone) {Â Â echo ' Â Â <form name="editform" method="post" action="editform.php"> Â Â <p class="body"><b>Title:</b>' Â Â Â Â $t ="Dr","Professor","Mr", "Ms" Â Â Â Â echo "<select name='selectTitle'>"; Â Â Â Â foreach ($t as $value) { Â Â Â Â Â echo "<option value="$tvalue"";
View Replies !
View Related
No Database Selected
Im running twice the same website: - one for the public - one for private testing Everything is moreless the same, except some config variables in the php and the replacement of css directories. However on the test server im getting a no database selected: mysql_query('sqlhere') doesnt work mysql_query('sqlhere',$conn) does work So somehow on my test server it is not taking the only open connection, but wants it specified. Code:
View Replies !
View Related
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 !
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
How To Give A Value To Non Selected Checkbox
I would like to get a value for a non selected checkbox in a form. Imagine my form contains : <input type='checkbox' name='t[0]' value=Ƈ'> <input type='checkbox' name='t[1]' value=Ƈ'> When I analyse $t, if first checkbox is not selected and second is, I have : $t[0] has no value. $t[1] equals 1 and count($t) equals 1 I would like to find a way to get : $t[0] equals 0. $t[1] equals 1 and count($t) equals 2
View Replies !
View Related
Resize Only Selected Images
I have an image upload script that is resizing every image that a user uploads. What I would like to do is have a check box added to the upload form that a user can check to resize the image if they want to or leave it unchecked to just upload the image. So if the box is checked the original image gets uploaded and a resized image is created as well If the box is not checked just the original image uploaded. I tried adding a check box but every image still was resized - checked or not - Im assiming because it was in the foreach loop so I dont know what to do. Code:
View Replies !
View Related
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
Radio Button Selected
What I wish to do is have a radio button pre-selected depending on what is pulled from the database. For example if I had 2 radio buttons: o Yes o No One has the value 1 and the other has the value 0 If 1 is selected from the database then Yes is pre-selected, else 0 is pre-selected. How would I do this?
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
Randomly Selected Account
I have an application that I need users to be logged into automatically without creating an id. I have setup a database with users names as user1, user2, user3, and so on, and a field called in_use. I can make php set the in_use field in the database to yes when the page is loaded and I can get php to select the first available username. I can't however get the database to reset the in_use field by itself (if the user closes the window insted of clicking log out).
View Replies !
View Related
Jump Menu Selected Value
I have a set of 2 menus where the values of the 2nd are dependent on the value selected in the first. Yes, I will (eventually) convert this to a javascript process, but for now I am content reloading the page. I have created a jumpmenu that reloads the page with the state passed in the url (ie. community.php?state=NY). This determines the values displayed in a second (dependent) menu which then lists the counties available for that state. Code:
View Replies !
View Related
Collecting Selected Options
how I can achieve the following: Page1 Within form is a list of 100 questions each with their own checkbox, however the user must select to answer only 10 of these questions. So they select the 10 questions they wish to answer. Page2 Then display the 10 questions they selected. I believe this is something straightforward,just i cant get started.
View Replies !
View Related
Get The Data For The Selected Item And Not The First It Comes Across?
I use the GROUP BY command in one of my queries, the trouble is although they share a common field sometimes the data differs in other fields for an individual record. Is it possible with the command to get the data for the selected item and not the first it comes across? For instance if the data is this ID, Cat ID, Name, Data 1, 1, Name 1, bla bl1 2, 1, Name 2, bla bl2 when grouping by cat id and group concat the name, irrespective of the id that is input to the database the query will deliver. Cat ID: 1 Name: Name 1,Name 2 Data: bla bl1 What I want is for the query to output 'bla bl1' when the id on the php page is 1 and 'bla bl2' when the id on the php page is 2. Is this possible? If the way I've explained it is confusing let me know and I'll try to make it clearer.
View Replies !
View Related
Multi Select Box Selected
i have two tables: staff ------------ stid, staff 1| lien 2| tony 3| tom 4| henry bill ---------- billid, stid 1| 1,3 i need for it to display all the staff from the staff table in a multiselect box then have the staff in the bill table selected. i can't figure out how to do this. Code:
View Replies !
View Related
Display Selected Records
I have a table on a form which contains records that can be multiple selected by checkboxes. A submit button sucessfully sends the record IDs of the checked records to the next page. I want to display the records that were selected via the checkboxes, but the problem is that I get only the first of them.
View Replies !
View Related
Database Selected Error
I built a web application for our IT department to handle PC Cases. I used PHP/MySQL for the application. Everything for the most part works fine except every once and a while when you are navigating the pages I get a blank white page with the error "No Database Selected" in the top left hand corner. It seems like the database is timing out or something, or maybe its getting too many queries, I'm just not sure.
View Replies !
View Related
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 !
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
Display Emails Once Selected
I have an admin area where i can send emails to any selected member using using checkboxes. On submission it sends you to the next page where the email is then sent. All the emails that have been selected are then displayed Code:
View Replies !
View Related
Showing Selected Parent
In my CMS, I have parent and children categories in one level and in one table (id, name, subcat). What i would like to do is, in PHP of course: Upon editing a category, in a dropdown box, show selected, the parent of the category. if there is no parent, show selected, a message saying "Not a subcategory". In the selection though, still shows the parent options as possible selections. } Can anyone help show me the right direction I need to go with this? Do I need a join in my sql or do I need multiple sql queries? Moreso, how do I accomplish this after the query is completed? I am not sure how to go about this.. Code:
View Replies !
View Related
|