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?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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>
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.
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:
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.
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 Ɖ' 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.
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.
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.
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?
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?
Multi User Form Search
I have a multi page form that creates forms on the fly and keeps an array of values as you move through the code. I want to store these values as the pages are created so I can incorporate a User Search that automatically fills out the form information from a mysql database query. The program logic is fairly straight forward. I am try to figure out the best way to save the variables as it moves through the dynamic pages. I want to be able to do a database search and return to the same instance of the page that it originated from. Sessions and Cookies both give me Header Cache errors. Code:
Multi-pages Form Using Session Variables
I am trying to break a very lengthy php form into several pages but I am having some problems partly b/c For testing purposes I created 3 very simple forms: page1.php, page2.php and page3.php which shows contents from page1 and page2. Eventually I would like to send this data to the database. PHP Code:
GET / POST Conflict In A Multi-page Form.
Wonder if anyone can help with this problem: I am using an app with several pages, using a session to track vars between the pages, and using an image map to re-direct back and forwards between the pages. The way I redirect is when the image map is clicked on, it posts to a page called 'control.php' which passes the POST vars to the corresponding SESSION variables, then redirects to another page, based upon the co-ords of where the image map was clicked upon. I have added text links at the bottom of the page: i.e. <--- previous page ----> next page but because the image map POSTs the data to 'control.php', I can't really add a GET query string to the link at the bottom of the page, because nothing will be POSTed. ....But then again, I can't add a POST link to the HREF, because it won't pass the co-ords, and I can't add a special variable to identify the link to the control form -i.e. control.php?link=3 (as I could with a GET) and re-direct accordingly. So, after hours of thinking about this, I'm stumped. The only idea I have is to hack the image map up into smaller pieces, add ALT tags to each one, and make do with it - or add NEXT and PREVIOUS submit images at the bottom of the page too. If I make do one with large image map, it is no use to someone who is visually impaired and relies on ALT wordings. Is there any possible way to achieve what I am trying to do ?
Basic Multi-form Database Upload Question
I'm learning php and mysql. As an exercise, and in order to create something I need, I am building a page builder. So how would the following process take place best with php and mysql? I have a series of form pages containing inputs for collecting information that will be used to build a 'breeder listing' page. Once the user has filled in each page and submits the third page, he will be sent to a review page showing how his listing page will look except with an 'Upload' button and an 'edit' button, allowing him to review his page. This will then create a new page. If I understood how this process is done, I can look up all the details, but I'm confused on the process.
Processing Data From Multiple Multi-line Textareas Into A Multi-dimensional Array
I know that this sounds like something overly complex - because it is. However, if I can keep the user interface the way it is, my users will be ultra happy! That is the goal... In general, this is an inventory receiving piece of an overall larger web-based ERP system. What I have is a form in which I have a dynamic number of multline textareas for inputting (possibly barcode scanning in) many serial numbers per line item recieved. For example: lineitem01 = widget01; qtyReceived = 2; lineitem02 = widget02; qtyReceived = 3; lineitem03 = widget03; qtyReceived = 10; This would display a form that will generate 3 textarea elements (1 per lineitem received). Inside each textarea element will be input the serial numbers for each of the widgets received per lineitem. i.e. 2 serial numbers will be entered for widget01; 3 for widget02; and 10 for widget03; So, what I am trying to do is pass this data over, possibly as a multi- dimensional array to another form ( or possibly $_SERVER['PHP_SELF'] ) to update a MySQL database to store the widget/serial numbers.
List Subscribe Form
trying to make a simple subscribe form for an email list like so... $to = "news-subscribe@mysite.org"; mail($to, "subscribe", "subscribe", "From:$subscribe Reply-To:$subscribe"); but the email list never confirms the subscription by email so can't figure out whether its getting the email or not? nether the subject or body text are necessary, its the address that does the command, any ideas anyone?
Form Entry List
I have a form with one box into which users type a few words (an email address). That entry is emailed to me. I need to copy each entry into one text file automatically so I do not have to copy them manually out of each email one at a time. The result would be one text file with the entries listed down the page, one by one.
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:
How To Post A Form To A List Document
I'm not looking to learn alot of PHP right now but i am learning enough to get done what needs to be done. I need to no how to make a list document that gets and posted form from a different document and puts it into a list, . heres my form from my input.htm Code:
Dynamic Form - How To Set Values Of A List
I have a form with a list/menu in it that is populated with records from a database. The items in list#2 are based upon what is selected in list#1. I have been able to use a combination of php and javascript to get it to work, but the javascript reloads the page to get list #2 to refresh - and that clears out any other fields that have been filled in. Instead of javascript being called for the 'onchange' event for list #1, I'd rather it call php when list#1 is changed and so reset the values in list#2. OPTIONS: 1. I thought I could have a php function that is called (i.e. onchange="<?php reload();?>" but I can't figure out how to set the values of the list from within the php function. How to reference form objects with php?
Multi Sorting Multi Dimensional Array?
I have been using usort to sort my multi dimensional arrays ... function cmp($a, $b){ if($a[0] == $b[0]){ return 0; } return ($a[0] < $b[0]) ? -1 : 1; } usort($searchResults, 'cmp'); Which works fine, but I need to sort by one element in the array, then another, preserving the previous sort. lets say the array is as follows: array[0] = array[0] = foo [1] = 2 [1] = array[0] = foo [1] = 0 [2] = array[0] = bar [1] = 1 [3] = array[0] = bar [1] = 0 [4] = array[0] = foo [1] = 1 [5] = array[0] = bar [1] = 2 Initially, I sort the array in to groups based on array[?][0] using usort as above so the output is : foo, 2 foo, 0 foo, 1 bar, 1 bar, 2 bar, 0 Next though, I would like to sort this output by number (array[?][1]) in the groups so that the output is : foo, 0 foo, 1 foo, 2 bar, 0 bar, 1 bar, 2 Is this possible? I am completely at a loss as to how to do this ...
Problems With Form Processing: Array_key_exists() And While (list($k,$v) = Each($arr))
I have an HTML form I'd like to process. <select name="items[]" multiple> <option value="doughnuts">Hot Doughnuts</option> <option value="coffee">Hot Brewed Coffee</option> <option value="tea">Hot Tea</option> <option value="cake">Sponge Cake</option> <option value="chips">Hot Chips</option> </select> The problem I have it where I follow the Programming PHP book: // Should the 's' be the name of the select tag, or the name of // the submit button? if (array_key_exists( 's', $_POST )) { $selected = "User selected these options: "; while (list($k, $v) = each($_POST['items'])) { // Is $v "doughnuts" or "Hot Doughnuts"? $selected .= "$v " } // ... }
Retrieve Array From FORM List Of Values?
I have created a form where a user selects 2 items from a list of 8 values. That form field is called "choices" and returns a value to the php file as $choices. This form posed no problem when I only allowed a single item to be selected, but the client now needs to have 2 items selected at a time. The problem I'm having is that I don't know how to turn the multiple selections on the form in to an array. I thought the $choices variable would automatically become an array, but Using[color=blue] > for ( $i = 0; $i<2; $i++ ) > echo "$choices[$i] ";[/color] only returns the first two letters of the last selected item value. And [color=blue] > foreach($choices as $articles) > echo $articles. ' ' ;[/color] Returns an invalid argument. While echo $choices returns the second item selected in the list, but not the first. It appears that the variable is replacing the first item selected with the second rather than returning an array.
Putting Form Error Messages Into A List
I have some form validation and I want to put all the error messages that are displayed into a bulleted list. I have seen it done with more complicated validation using OOP but I don't know enough to do that. How would I add these error messages to a list if they occur? Code:
Calling A Php Function From A Form Selection List
I have a function that will read records from the database and populate an area of my webpage based on a value selected from a list box. I have got it to work fine if the user hits a submit button but I was wondering if it possible to perform the function dynamically each time the user changes the value in the list box.
Print Array In List/menu Form Object
how i print a full column array into a list/menu form object, so that the text links to their respective page.....it is basically for a list of interviews so you click on the band name and then goto the interview page.
Retrieving Contents Of Select List On Form Submit
On an HTML form, I have a select list that is fed dynamically with detail records when the master record is displayed on the form. There is also a second lookup list, and want to allow the user to dynamically select from this list and add to the first list. I also want the user to be able to dynamically remove from and reorder the first list. I think I can do all of this with JavaScript. The question I have, is how can I retrieve the contents of the first list when the user submits the form? I need to get it back into a php array so I can update and add the proper database records.
Populate A Drop Down List In A Form On The Basis Of A First Selection
I have developed a form to register a property in a db. The form needs the selection of a country and then based on that selection the selection of regions from the selected country. I have a program which allows selection of a country and then a region but it uses java script which I would like to avoid. I also just wanted one submit button if possible. Code:
Displaying Data From Mysql Database In A Drop Down List On Form.
I'm trying to do is display data from two different mysql tables from the same database in a drop down list on a html form. I have a fixtures table with the player1(userid), player2(userid), gameid, game, score1 and 2, what I want is to use the userid to get the players first name and surname from the members table (as it is a unique id), I need to do this bit before displaying it in the drop down. I think i need 2 querys to do this but when I have tried it it just echo's a blank value or the userid not the forname and surname that I want. I'm using the fetch_array function but just can't see where I'm going wrong, Code:
Multi User/ Multi Page Redirect To Particular Clients Page
I need all of my clients to be able to go to ONE login page. based on their user ID number and password be able to login to their particular page, I do not want them seeing any of my other clients information. seems easy... now why cant i figure it out. I want the back end of it in mySQL, with a way for: admin to easily update the information located in there...ie: go to client 1 add new invoice information, new expiration date, etc. clients to easily update their billing information, etc from their personal page, is a must also. I just want to know if going with PHP is the best bet, or if there is another way..
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 = Ƈ') 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?
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.
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:
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:
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
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:
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?
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?
|