Newbie: Getting Index From Dropdown On Onchange Into Php Var
This is very new to me, scripting languages. I am trying to get the /select id off of a dropdownlist, which really does not drop down and is more like a flat list??, at an onchange event. Then move it into a php var to retrieve different data from db. Not that it matters but I load about 1200 items in to the list and was surprised how fast it is.
Could some one give me some direction?
// // Handle the data coming back echo "<FORM NAME=author>"; echo "<SELECT NAME=author_pk SIZE=20 COLS=20 ONCHANGE=getPK()>"; while ($rows = mysql_fetch_object($result)) { echo "<OPTION VALUE=".$rows->id.">". $rows->TITLE." ". $rows->lastname.", ". $rows->firstname. $rows->middlename. $rows->SUFFIX. "</OPTION>"; } echo "</SELECT>"; echo "</FORM>"; echo "<script language=Javascript>"; echo "function getPK() {"; <? $location ?= "document.author.author_pk.options[document.author.author_pk.selectedIndex].value "; echo "}"; echo "</script>";
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Index Page Query From PHP Newbie
index.html page I wish to have a link called "Today's message" that contains a bit of PHP to fetch the message of the day. I have this working from a daughter test page which has the extension .php. When I implement this link from my Home Page I want the Home Page to still be named index.html How would I implement my desired operation?
Dynamic Dropdown And Hardcode Dropdown In Select Form
I have plenty of examples of dynamic dropdown choices but none of hardcoded dropdown choices. The ultimate goal is to have a job with various tasks and to track the status of those tasks for a given job. I've used one of the tutorials here to begin the process. Below is the code I have to add work on a given task. Perhaps I actually need to "Update" a job as opposed to "add". But the problem of the moment is I can't seem to hardcode one set of my options. This is the code I have: PHP Code:
Onchange
I want to make a php document . I have comboxbox and checkboxes. I want that some checkboxes would appear,some don't changing to which value chosen for combobox. As I learn I should use onchange ,but I don't know how to do.
Change A Variable Value Upon OnChange Method
I use a combo box 'select' in a form, now, what I am going to do is to change an SQL statement when user change the value of the combo box. I tried many ways and still it doesn't work. May I know is there any efficient way to do it?
Calling Variable In Onchange Function
I am using a javafunction (onclick in select) in which i am calling a function in php (thats why i send this to both php and javascript newsgroups). in the onclick i call the function "Place_Selected" with the value from the select (naam_keuze.value) in the function the value becomes the $zoek_id and searches in the database for the record with the id of $zoek_id the naam_keuze.value does not give the value to $zoek_id When i replace naam_keuze.value for a number (15) i works great. WHAT AM I DOING WRONG? This is my code Function Place_Selected($zoek_id) { include("data.php"); $link=mysql_connect($db_host, $username, $password) or die("Database error!"); mysql_select_db($database , $link)or die("Couldn't open $db: ".mysql_error()); $sql=mysql_query("SELECT * FROM specialismen WHERE id='$zoek_id'"); if ($sql) { while($blah2 = mysql_fetch_array($sql)) { $newsid = $blah2['id']; $sticky = $blah2['naam']; } } return("document.form.achternaam.value='$sticky'"); } <select id=naam_keuze size=1 name=keuze style=visibility:hidden onchange=".Place_Selected('naam_keuze.value').";document.form.voornaam.value =naam_keuze.value;> <option value=0>Kies $options </select>
PHP PRINT Statement With OnChange Event
I have tried every variation of the "onchange" statement below without any actual reloading of the page. I am hoping that the PHP PRINT statement is constructed wrong, otherwise it is javaScript error an needs to be posted in the javaScript newsgroup. The FireFox javaScript Console reports the following message: Error: missing : in conditional expression Source Code: location.href=themes.php?scheme=(form.color_scheme s.options[form.color_schemes.selectedIndex].value) My Code for the dropdown box is: <form name='color_schemes' method='post' action='themes.php' > Select a scheme: <?php print "<select name='scheme' size=Ƈ' onchange='location.href=themes.php?scheme=(form.co lor_schemes.options[form.color_schemes.selectedIndex].value)'>"; //populate the dropdown selector box... $counter = 1; foreach ($schemes as $scheme) { if ($selected_theme == $counter) print "<option value = '$counter' selected>$scheme</option>"; else { print "<option value = '$counter'>$scheme</option>"; } $counter ++; } ?>
Call PHP Form Onchange Event
I have a trouble when i want to use a list box, I want when I choose an item on it then data in textarea'll change too.
Linking Php Function In Onchange Event
i have probelm in linking php function in onchange() event. I am new to php. Im my database (test) ,i have per_det as table whic have two cloumn(eno, ename). My query is list all eno from database in combo box. when user select the eno the respective name from database should be displayed in textbox, Code:
Select Menu OnChange To Update Text Boxes
I've a select menu filled from mySql, So when I change the selection.. I want to change 3 text boxes also by the same row of database that is = to the row of the select menu. So i tried a lot but failed.. cuz I cant send to javascript the updated values when the selected menu change.
Index.htm Going To Login Page And Sending Back To Index Page
1: A visitors visits a.html page. decides to login and post comment. goes to login page and logs in then I want to send him back to a.html page how do I do that? Here is my login page and login.php page. 2: Same as above but I want to send them back after some time... while I make them view the error, why they have not been able to login. Code:
Which Index To Use - Primary Key, Index, Etc
I have the following tables (simplified example): countries: code_country (char-4) , name_contry) breweries: code_brewery (int-4), name_brewery) coasters (code_coaster (char-8), description, code_country, code_brewery) code_coaster is formed by the combination from code_country + a correlative number: for example CH-33, INDO-102, etc How should I define the indexes so that the querries will be optimized? I've thought about the following: code_country: unique in table country code_brewery: unique in table brewery code_country: index in table coasters code_brewery: index in table coasters code_coaster: unique in table coasters I don't really understand the difference between primary key and unique. Should I use primary key instead of unique?
Looking For Dropdown Help
I have a dropdown in which i want it to open a soundfile when selected. So, how do I go about this. The form will get submitted, and through a series of conditional statements it will point the right selection to the right if statement. but what do I put in the if statement to get it to open a realplayer with my ram file?? Here's what I got so far. Code: <FORM ACTION="<?=$_SERVER['PHP_SELF']?mode=changedropdown?>" METHOD="POST" NAME="sermondropdown"> <P> <SELECT NAME="sermons" SIZE="1" onchange="this.form.submit();"> <OPTION VALUE="pleaseselectasermon">Please Select a Sermon <OPTION VALUE="082403Daniel_1_1-8">August 24, 2003 Daniel 1:1-8 <OPTION VALUE="083103Daniel_1_1-8">August 31, 2003 Daniel 1:1-8 </SELECT></P> </FORM> <? if('changedropdown' == $_GET['mode']) { $selection = $_POST['sermons']; if (?Daniel_1_1-8' == $selection) { } elseif (?Daniel_1_1-8' == $selection) { } ?>
Dropdown
I have a dynamic drop down that needs to be populated from different columns in a database. The problem I'm running into is that sometimes fields do not have a value. So I would rather those didn't print out. The code below prints out the blank fields. I know I need to loop through and check for an empty value, but I'm drawing a blank on the how part. Code:
Dropdown Possible With PHP ?
i'm looking for a way to do the following : 1. selecting data from a MySQL database 2. putting one field into a dropdown 3. after selecting a value from the dropdown follow some more php code step 1 is no problem, step 2 is no problem with the html select statement however this leaves me on the client side. After this i'm not able to return to the server side to execute some more php code, with the onchange attribute i can start some javascript but i want ( read need ) to use php code. Concrete question : is there a way to create a dropdown in pure php code ?
Dropdown Box
I currently have a dropdown box on a page. What I would like is that when a user selects something from the dropdown box it automatically changes the display of another box.
Value In A Dropdown
I have a piece of code where I get the player_id value from the url at the top of the page. Rather than this I want to get the value from variable named $player_one. Code:
Dropdown Box And A Query
Heres my situation: In a form I want to read the categories listed in table $inv_table and present them in a dropdown window so the viewer can choose and add to a different table. The script below works with one glitch. There is a huge white space on the page above the dropdown box. This will get me by but it isn't too purty. <td valign="bottom"> <a name="theform"> <select name="catname" size="1"> <? { $result = mysql_query("SELECT DISTINCT category FROM $inv_table ORDER by category",$db); while ($myrow = mysql_fetch_array($result)) { echo "<option>".$myrow["category"]."</option><br>"; } } ?> </SELECT> </td>
Dropdown List
I have a Dropdown list with Select with 1, 2, 3, 4, after select on of them it bust to refresh the page to what you select but it don't do it. PHP Code:
Dropdown Menu
I want to upload a feild values into a dropdownmenu. can anyone help me how to write in php code.
Dynamic Dropdown?
I am posting a code for dynamic dropdown by Leon Atkinson, it works fine but i have a doubt: I tried to add another functionality to it where i got stuck! Once the city also gets selected from the second drop down i wanted that on clicking the submit button it should go to some html page wrt to the city choice. Code:
Dynamic Dropdown Box
im looking to have two drop down boxs one with makes of car and the second drop down box to automatically populate with all the model of that particular make of car. there are about 50 makes and upto 50 models per make. I just would like to know the best way to do this - javascript or use a database? it would be a lot of code todo it in javascript wouldnt it?
Dropdown - Default Value
I want to be able to have a drop down list that doesn't necessarily have the first item as the default. The content is being populated by PHP so I have no idea how to do it.
Dropdown List
i am trying to get two dropdown lists working on a page. How do i go about this. For example, I have 1 table which holds countries and cities. When a user selects a country in the first dropdown list, i'd like the second dropdownlist populate with a list of cities etc. from my database.
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:
MySQL Dropdown
Is there a way to make a dropdown by getting the options directly from the database? And I'm using this as a form so it has to have a name so I can call upon the value and do something to it. Example to what I want to do: - I have a database table named members and in that table, it has 3 columns - name, age, sex. What I want to do is make a dropdown inside a <form> using the data from the database. And then when the person selects the name of the member and presses submit, it deletes the row with that name from the table and the database.
Change Dropdown Value
i've two dropdown fields 1) products - (mobile phone, camera, webcam, tv, dvd player and etc 2) accessories how accessories field can be changed if visitor selects product. for example: if visitor selects TV, accessories field should automatically changed with cable wire, electric board and etc (without reloading) another example is www bestessays com/order.php when you'll select "Thesis" from type of document, urgency and cost per page values will be changed.
Months Dropdown
I'm looking to do a dropdown with the months in the year starting with this month and going on for 12 months, ie. the selected month is April 2007 and the last month is March 2008, does anyone know how to do this using PHP?
Last 3 Months Dropdown
I need to come up with something that will take the current month, for example this month is april. It would create a drop down list like Feb 1 - feb 30 march 1 - march 30 April 1 - April 30 Basically the last 3 months, including this one. Then I am going to need to save the month as the value, so I can pass it to the script so I know what date ranges I am looking for. I can't think of a logical way to do this, and still account for the fact that some months have 29 days, some have 30, and some have 31.
Help With XML DOM Using PHP (XML Newbie)
I tried posting in the XML board, but there isn't much traffic there, so since I'm using PHP to use the XML DOM, I figure I'll try posting here too... sorry if this qualifies as a cross-post. I've read through (skimmed, really) the PHP & XML articles on devshed, in the XML section... and I've been playing around with using the XML DOM, but have a few questions. My XML document looks something like this: Code: <?xml version="1.0"?> <SITE> <SECTION1> <PAGE1>This is the first page of section 1.</PAGE1> <PAGE2>This is the second page of section 1.</PAGE2> <PAGE3>This is the third page of section 1.</PAGE3> </SECTION1> <SECTION2> <PAGE1>This is the first page of section 2.</PAGE1> </SECTION2> </SITE> Now, I'm using the DOM to extract the root, and then list all of the children of the root. However, what's happening is that even though I have 2 children of the 'SITE' node, my code is reporting that there are more. I've checked the type for these other nodes, and they say they're text objects, but I can't figure out what they are. Here's my code:
Newbie 2
Notice: Undefined variable: username in /home/fhlinux169/c/ clashoff.co.uk/user/htdocs/create_entry.php on line 11 Notice: Undefined variable: password in /home/fhlinux169/c/ clashoff.co.uk/user/htdocs/create_entry.php on line 11 Ive got a new error message please help.Am trying to setup userlogin on my website. This is the code: <?php mysql_connect("localhost","root") or die ("Could not connect to database"); mysql_select_db("user") or dir ("Could not select database"); if ($_POST['submit'] == "Register") { $query = "insert into users (username, password) values ('$username', '$password')"; mysql_query($query) or die (mysql_error()); ?> <h3>You are now registered</h3> <a href="index.html">Go back to main page</a> <?php } else { print("not registered"); } ?>
Can Anyone Help Out A PHP Newbie?
Just now learning my way around PHP, and I'm having trouble with something that I'm sure is a breeze for more experienced PHP coders. Hoping someone can help. I have a Web directory filled with text files that I need sorted alphabetically. The details are: · The files are numbered sequentially with a filename in the format #.txt, such as 1.txt, 2.txt, 3.txt, etcetera. · I need to sort them by a client name that appears in the first line of each file. The files look like something like this: XYZ Corporation Aaron Winslow Contacted May 12, 2004 Entry Code 2355239 · It's crucial that the sorted files be renumbered sequentially, as a report routine that pulls reports from the files freaks out if it finds a missing number. They numerical order would have to match the alphabetical order. · All the files exist in a single Web directory with no other files, so paths are not a consideration. And since there is nothing in the directory but the files to be sorted, operations on the entire directory are possible. Can anyone suggest anything appropriate to accomplish this, even something quick and dirty? I've been doing bubble sorts for years in other languages, but I'm not up to speed on PHP enough yet to get it working. I could probably be tacky and resort to doing it in QuickBASIC, but who on earth wants to do THAT? ;-)
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:
Maximum Dropdown Size
I have a strange issue with dropdowns. Using php4, mySQL5, Apache 2 on a fast XP pro PC, I have a form which requires 5 dropdowns populated with indentical values. I extract the values using SQL and populate 2 variables and use a for-next loop to create the dropdown. The dropdown contains some 310 items! It works beautifully if I have 1 or 2 dropdowns but as soon as I add more it partially creates the 3rd and just stops until it times out! All 5 work because I have altered their positions but it always stops part way through creating the 3rd dropdown. I tried an alternative method by doing away with the variables and constructing the dropdowns with a 'while' statement reading through the results of my SQL and got exactly the same problem only 2 and a bit dropdowns. Stopping it running after a few seconds or several minutes makes no difference, it seems to reach a certain point and just stop - no error messages or anything! I have tried increasing the resourses in my php.ini file but this also made no difference. Can anyone suggest an alternative or a fix?
Populating Dropdown List
I am wanting to know how to populate the <SELECT> dropdown menu with all existing values from the DB and also have the value associated with that id selected. This is an updating area of my admin. Any ideas? Here's the code so far. At the moment it only retrieves the value assigned to that id. PHP Code:
Dropdown Lists From A Mysql Db
Id like to load a drop down list from a mysql database using php3 and create a link to that record. Does anyone have any ideas?
Advanced Dropdown Menu
I want to populate a dropdown menu with countries that are in one column of my table. I know how to do that, but I can't find how to eliminate multiple items. Some countries appear several times in different rows, but I only want each available country to be shown once in my dropdown list.
Mysql / Dropdown Menu
what i am trying to do is to make a system with a few input pages and edit and read pages.. so right now i got the input/edit/read pages working. (yay) But now I want to have on 1 input page a dropdown menu that reads its information from the database. and that if i go to the page i can select a value out of the db and submit that inside my form and that it reminds the value if i view or edit the page. So what i got now is a little system that is able to add/remove/edit a value inside a field called "drop01" Well now i got a other input page called "input01.php" inside this script i want to have the dropdown menu that reads its values from the "drop01" field. PHP Code:
Autoselecting A Value In A Dropdown Menu
I'm revamping my sites administration panel and I put in a dropdown menu to select the section to administrate (it was a LOT better than the list of links I had before, I'll probably update it some more though) and I want to know how I can autoselect whatever page I'm on in the dropdown menu, for example, here's the menu: Code:
Multiple Dropdown Menu
i attemp to design a drop down menu that call up data from a table for each drop down menu. Code:
Update Dropdown Instatly?
I have 2 dropdowns on one page, and well the second is controlled by the first. What I want is the first dropdown to select the value and then an instant MySQL statement to populate the second dropdown..
Populate Dropdown W/o Submit
Ive got some arrays; one array is most of the U.S states. the other arrays are names of clinics my company has within the selected state. I want to be able to select a state from a drop down and have another drop down next to it that will populate itself automatically.... without having to press a submit button.
Calling Dropdown Data From Db
I want to call data from the db and display it in a dropdown and make the selected option match the value of the record called. It thats clear? Code:
Dynamic Dropdown Lists
I am recoding a greeting card website. I am using dropdowns as filters for items in a DB, so when the user picks "animals" from the "theme" dropdown, the returned cards all feature animals, and when the user picks "birthday" from the "message" option, the returned cards all feature birthday cards. However, there are some combinations that don't return any results, for example "get well" "floral" cards. Code:
Smarter Way Of Doing Dropdown List?
I've got a dropdown list that is acting as a filter on a table, so the user can select a value and the page is reloaded only showing the matching values from the database. Now when the page reloads the dropdown was set to 'all' as it was first in the list, even if I'd selected a different value, this was confusing for users, so I added an initial <option> field which pulled the correct value from $_GET (code below) - however this is a little odd as it means the value appears twice! Does anyone have a genius solution to this? I've seen a <select selected="yes"> sort of thing around, but I don't know how I can tell the php to add this value dynamically? <select size='1' name='occupation'> <option>".$_GET['occupation']."</option> <option value='All'>All</option> <option value='Student'>Students</a></option> <option value='Professional'>Professional</option> <option value='Hobbyist'>Hobbyists</option> </select>
Empty Value In A Form Dropdown
Think that we have one dropdown form where we can choose countries from like this. <select name="country" id="dropdown"> <option value="Choose country">Choose</option> <option value="USA">USA</option> <option value="CANADA">CANADA</option> IF I have an SELECT I can easily set country = '$country' IF user have choosen some country, but when user not choose any country the selected one is "choose", is it possible do add All countries to $country so the SELECT formula include all countrys and not just get empty?
Classes And Dropdown Lists
The class below works fine. The problem I have is there's a dropdown list in the middle of the loop. The dropdown list gets its data from another table in the database. Which goes through the same class. So I have a loop within a loop. What I'm trying to do is ....
|