Determine Contents Of Listbox
How can I determine the values of a listbox, both unselected or
selected after submitting the form:
Code:
<select name="sel1" size="10" multiple="multiple">
<? PHP code populates listbox ?>
</select>
Do I have to use Javascript to determine the contents, like in the
pseudo code Javscript below. But how would you pass the Javascript
return value to PHP?
Code:
function listBoxContents(sel1)
{
var selLength1 = sel1.length;
var valuesPresent1 = new Array(sel1.length-1);
var i;
for(i=0; i<=selLength1-1; i++)
{
valuesPresent1[i]=sel1.options[i].valueOf();
}
return valuesPresent1;
}
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Listbox Problem
I am using two listboxes with multiple selection. I have moved the contents from the first list box to the second list box. But I am not able to get the value from the second list box.
Listbox And Its Selection
im trying to create a webpage using mysql and php. im using the below code to populate a listbox with playernames held in my database. once i select a name; im trying to make the page gather the relevant information from that users details to be displayed on the same page. for example if i select "MoFish" from the listbox, i want it to echo all MoFish's details in the page such as his: "age" "height" "weight" if i select "Berty" i want it to echo bertys details. how can i acheive this? Code:
Retaining Value In Listbox Array
i have designed an application that is a dynamic submission form. i have text fields and listboxes. now i am able to retain the values of the listboxes when i populate the listbox "manually"(single listbox) like this... <select name="title"> <option value="1"<?php if ($_POST['title'] == Ƈ') { echo 'selected="selected"' } ?>></option> <option value="Mr"<?php if ($_POST['title'] == 'Mr') { echo 'selected="selected"' } ?>>Mr</option> <option value="Mrs"<?php if ($_POST['title'] == 'Mrs') { echo 'selected="selected"' } ?>>Mrs</option> <option value="Mstr"<?php if ($_POST['title'] == 'Ms') { echo 'selected="selected"' } ?>>Ms</option> </select> Now this works flawlessly for example if the firstname text box is left blank and the user clicks "send" then validation occurs and the value in the "title" listbox is maintained and user is prompted to fix the error. However this does not work when i use a listbox that is dynamically generated in an array. <select name="title[]" //note title[] = an array of titles within the form <option value="1"<?php if ($_POST['title'] == Ƈ') { echo 'selected="selected"' } ?>></option> <option value="Mr"<?php if ($_POST['title'] == 'Mr') { echo 'selected="selected"' } ?>>Mr</option> <option value="Mrs"<?php if ($_POST['title'] == 'Mrs') { echo 'selected="selected"' } ?>>Mrs</option> <option value="Mstr"<?php if ($_POST['title'] == 'Ms') { echo 'selected="selected"' } ?>>Ms</option> </select> But my text boxes work(retain value on POST in the case there is invalid input on the form) <input name="fname[]" type="text" value="<?php echo $firstname;?>"/> i have tried a couple of scenarios and in my debugging i see that if i chose the "Mr" option and 'echo' to see if it is POST'ed, it is. However when the form reloads it reverts to the default empty value of the listbox? thought maybe something like //code above <option value="Mr"<?php if ($_POST['title'][$count] == Ƈ') { echo 'selected="selected"' } ?>></option> //code below But nothing...So how to retain the value of the listbox?
File Listbox Of Directory
Is there anyway someone could provide code to a soultion i need here. Basically i have a directory of all these files uploaded, and i need some sort of way for a php file to list all the items in that directory somehow, it doesent need to be special, i just need them listed so my users can see what is uploaded into that directory.
How To Use Selected Data In The Listbox For My Query..
I have a multiple select listbox and I pass the data using array in php. How can I use these records to my query, or in one select statement. For an example: I have a listbox of item codes; the user selects an item code/s to view it's inventory. The selected itemcodes will be pass on php using array and these records will be used as a query or search items on my database.
Calculating The Selected Prices In A Listbox
I am wanting to know how I can add the all of the selected prices in a listbox? I need to add the selected prices altogether. The listbox should have only the names of the products. The listbox should be like below:
Create Listbox Depending On Variable
I currently have a variable called $NumPlayers which contains a number between 4 and 8; depending on this value; i would like to create this amount of listboxes on my page. For example if the value of $NumPlayers is 6; I would like 6 listboxes to be displayed on the page with names such as "Lstbox1" "Lstbox2". I'm a bit clueless where to start; and was hoping someone could point me in the right direction.
Adding Multiple Listbox Items To Mysql
I want to be able to select multiple items from a listbox in a form and send the result to mysql blob. I only get one item to the bd. Here is part of the script. Item: <select name="itm" align="bottom" multiple size="2"> <option value="item1">item1</option> <option value="item2">item2</option> <option value="item3">item3</option> <option value="item4">item4</option> <option value="item5">item5</option> </select> "Insert into xyz set itm = '$itm'";
Change Record When User Chooses Option From Listbox
I have a combobox which has different peoples names which are pulled from fields in a database. Can anybody please show me some code that will change the recordset so say for example there were two records in the DB with three bits of data name, number and telephonenumber: John 10 01234567544 Frank 34 07883922332 and somebody selects john from the select box that in the two fields it shows 10 and 0123... and 34, 078839..... if they select frank.
How To Determine Whether GD Is Installed?
I am trying to install a captcha form that required those graphic libraries. I got the error message "call to undefined function" which according to the authors of the form suggests that GD is not probably installed or enabled. I created the usual <?phpinfo()?> report and the only part GD is mentioned is in the Configure Command section: ./configure'...'--with-gd=shared' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-ncurses=shared' '--with-gmp' '--with-iconv' Can you tell whether GD is installed from that? If I remember correctly, GD should have its own section within the PHP info report - but its not there. Since my host isn't very responsive to my requests, I was thinking that I should try installing GD myself. Server is running Apache/2.0.52 (CentOS). Anyone aware of any tutorials that might help preventing me from screwing up things?
How To Determine Current URL In PHP?
Is there a way that I can determine the current url/location (like the 'location' variable in javascript)? For example, if I'm at http://mysite.com/index.php, is there perhaps a fixed variable containing 'http://mysite.com/index.php' already available, or is there a function available to retrieve it? I want to use this to log certain hits on my site, so it would be nice to have a way to do it all in one page rather than integrating information sent with the help of javascript from another page.
Determine How Long It Was Since Last Logged In?
I can insert the date and time into a SQL table, but where do I go from there? What would I use to figure out the exact minutes since they were last on? Also, the minutes need to round to hours, and hours to days.
Determine Four Highest Numbers From DB
Got this interesting problem, I have a table and in there I have a field called itemid which is set to integer, and basically its a list of numbers. The problem is, how do you go about calculating the 4 highest numbers? I've tried using SQL command but I don't think I have the version which support sub selects select * from t where number in (select max(number) from t)
Determine Expire Session
I need know when the session expired. I intend to create two messages, one when the session was not created and other when it's expired. e.g: Was not created: Message: Login in the site Created, but expired: Message: Session Expired, please retype your password and login.
Determine The Type Of A File (gif Or Jpg)
I've written a very basic CMS using a PHP database thing (no MySQL). It lets me update a list of 5 descriptive texts, each relating to an image which is shown next to the text. At the moment, my HTML looks like this (simplified): <tr><td><img src="images/Picture1.gif"></td></tr> <tr><td><img src="images/Picture2.jpg"></td></tr> <tr><td><img src="images/Picture3.jpg"></td></tr> <tr><td><img src="images/Picture4.gif"></td></tr> <tr><td><img src="images/Picture5.gif"></td></tr> which is very inelegant as I have to repeat all the information. I've already written the script to create the 5 table rows dynamically, using a "for" loop with the counting variable $i, so that I can simply write one row and substitute the Picture number with the variable: PHP Code:
Determine If Image Is Grayscale
i'm a bit new to PHP - i've been messing around with the GD2 image functions and was wondering: i see a lot of information about converting a color image to grayscale but i can't figure out how to determine whether an image (GIF or JPG) is grayscale in the first place. is there a way to do this in PHP?
Determine Number Of Entries
I have a form in which the user can add more textboxes as need be: Ing1 Ing2 Ing3 .... There could be 1 input or there could be 30... How can I, in php, determine the number of input controls so that I can then loop through them one by one and process their data?
How To Determine What Country Viewer Is From
i'm rather new to php and would like to know how to determine where the viewer is from. ie. what country. so if they have a .ca i can display canadian funds, .com/.us american funds, and .uk for pounds. is there a function that can be used for this or is there a way to set the domain to a variable and extract it from there.
Automatically Determine A Swf Dimensions
I am not sure whether you are actually able to retrieve the dimensions of a flash game from code. But is done seem that Miniclip.com are able to do it, but I am still not sure whether the dimensions are being retrieved from the database or not. Code:
Determine Field Type
When a form is submitted I can get the field names and the entered values with $_POST, but is there a way to determine what type of field? For instance, can I determine if a field was a textarea or an input field?
Determine A Forward Email Addy
i have an application that sends out mail from flash. in each mail there is a link for the viewer to click on. when the viewer clicks the link blah.php?email=email@address.com it updates the database adding their email to the list of people who have clicked that link. i want to be able to track emails that have been forwarded. the problem is if someone forwards, it will forward with their email attached to the link instead of the recipients. is there any way i can grab the recipients email and put it in the link?
How To Determine Which Button Was Pressed On <form>
I am having a heck of a time trying to understand how to use graphical buttons in my PHP scripts to interpret user selections. A great example is the list of buttons across the top of this forum (user cp, register, calendar, etc.). Now, I know how to create an <a href><img></a> graphical link and an <input type="image"...> button element for a form, but what I cannot for the life of me figure out is how to tell on a subsequent POST of my form which, of many graphical buttons, was pressed. PHP Code:
Uploading .png And Can't Determine File Type?
I'm currently creating a page where users can upload images and the server will save them to their respective places, but I've run into a snag of sorts. I currently check to make sure that the file being uploaded is an Image file, but only jpg/gif/png. If it is not one of those three, it rejects the upload. If it is, it will save the file to the server. Now my problem is that when a PNG is uploaded, there's no filetype associated with it. If I check the jpg and gif, I'll get image/jpg and image/gif respectively, but when I check the png, I get nothing, there's nothing returned. Does anyone have any suggestions or maybe seen this before? Also, I don't want to go and allow any image type to be uploaded. I'd really prefer to allow only those three types.
Algorithm To Determine Download Time
Anyone got an easy algorithm to find out the estimated download time of a file on a specific speed? I've been trying to figure this out for about a week now, to no avail.
How To Determine If A File Is UTF8 Encoded?
I need a check, if a file is utf8 encoded. I only found the php-functions 'iconv' and 'recode'. But it seems it´s not possible to determine the encoding with them. Isn´t there any similar function to the 'file'-command on linux for php?
Determine Folder A Script Is Running In.
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running in.
Determine Free Disk Space
Is there a way that PHP can determine the amount of free disk space (Linux system)? I have tried to manipulate the output from $df -h but it's not really working properly.
Checkboxes In A Form To Determine Whether To Display In Results
I am making an effort to put checkboxes in my form that will determine whether to display that column or not. This is my first time doing this with PHP and I am hoping you gurus can assist. I have gotten some extremely great assistance in the past, so I am looking forward to any recommendations. currently my form is as follows:
How To Make PHP Determine If POST Variable Is Existant
if (!$_POST['uploaded'] = NULL){ //If what was posted was NOTHING then $treC = "0"; } else { $treC = "2"; } No matter what, it keeps making the variable equal to "0," even when something WAS posted. Does anyone know what I should be replacing "NULL" with? I tried with 0's, ||'s assigning initial values to the posting form such as 0, nothing has worked so far.
Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution. So it goes <select name='status[]'>... <select name='resolution[]'> Then i have a another php page. $status = $_POST['status']; $resolution = $_POST['resolution']; Now my question is, how do i do the sql query statement? mysql_query("SELECT * from bugs where status=$status and resolution=$resolution"); The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.
Determine Image Information On Image Stored In MySQL BLOB
I store images in my DB as BLOB. When I want to place them in an html table, I want to determine the width of the image in order to asign the correct width to the column inside table. For JPEGs this is working fine, this is my code: $image = @imagecreatefromstring($r["foto"]); return @imagesx($image); where $r["foto"] is the field selected from the db which contains the image. For GIFs however, its getting really on my nerves !! I know imagecreatefromstring is not supported in gd2 and I tried several thinks. None of them worked ! : - $temp = tmpfile(); list($width, $height, $type, $attr) = getimagesize($temp); echo $attr; gives me :Warning: getimagesize: Unable to open 'Resource id #6' for reading - $handle = fopen("/tmp/tmp.dat", "w+"); fwrite($handle, $r["foto"]); list($width, $height, $type, $attr) = getimagesize($handle); echo $attr; gives me : Warning: getimagesize: Unable to open 'Resource id #6' for reading - Doing this with imagecreatefromgif($temp); wont work either ! Can somebody help me out please? by telling me what I'm doing wrong or what I should do.
PHP Date Question: How To Determine The Date Each Of The Past 3 Sundays
How can I determine what the date was (in YYYY-MM-DD format) last Sunday, and the Sunday before that? For example: Today is Thursday, August 18, 2004 (2004-08-18). I would like to have the following variables: $this_past_sunday = 2004-08-14 $two_sundays_ago = 2004-08-07 $three_sundays_ago = 2004-07-31 etc. etc.
File Get Contents()
I need to verify, (working on the HTML section of a mailer), If in my php.ini: allow_url_fopen is On Will file_get_contents(file URL) called as follow: $mailer->Body = str_replace('{MEMBER_NAME}', $member_name, file_get_content($htmlBody) ); Allows the file to become my email body? where $htmlBody comes from the DB...
Getting And Using Contents In A Folder
I want to make a photogallery/slideshow with PHP... The 'gallery/slideshow' would show up inside a new window. basically, I just want links with possibility to go: - forward - back - to the very beginning - to the very end - away (close the window) Can I use PHP to determine the contents of the folder with the pictures and then use variables to determine which photo to show, and what URL's should be generates for the arrows? So each folder with a series of photographs would have one PHP file and the pictures themselves in them (it's not a problem to rename them). Should be simple enough, but I'm just starting out with PHP, and I'd like to have something working as soon as possible... the website I'm working on is about to launch soon (my first 'commercial' web project :) ), and this is about the only thing left that I still have to sort out how to do...
|