PHP - How To Add A Drop Down Menu By Pressing A Button
I'm not sure how this would be done with php or something else, what I want is to have a button and when the button is pressed it creates a drop down menu and if it's pressed again then it creates a second drop down menu. I've been googling but haven't found anything yet if someone has an idea or a tutorial that they could direct me to that would be very helpful!!!!
Any help is greatly appreciated, thanks in advance!!! Similar Tutorials
I Need To Show Data After Pressing Browser's Back Button [accidentally Pressed Enter Instead Of Tab]
not sure if this will find an answer but I am posting anyway. Any help is appreciated....my coder has left the team and no matter how I invite her to come and do some bug squashing, her new schedules won't fit a re-visit into my little aplication...I am eager to delve into the codes at my very low knowledge of php. I have initiated reading and is still trying to teach myself...but of course not as fast as the app needs the patch...here's the meat: I cannot figure out how to retain the inputted information once submit is pressed. I want the user to enter their first name, last name, hours of work, and hourly pay rate. Then, I want them to press submit. Their pay will be calculated and displayed, but I still want their inputted information to be visible. How can I do that?? Here is my code: Code: [Select] <html> <head> <?php $pay = $_POST['pay']; $hours = $_POST['hours']; $extra = $_POST['extra']; $rate = $_POST['rate']; if ($hours > 40){ $extra=$hours-40; $hours=40; $pay=($extra*1.5*$rate)+($hours*$rate); } else { $pay=$hours*$rate; } echo "Your pay is: <br /> $ $pay <br />" ; ?> </head> <body> <form method='post' action='pay2.php'> First Name: <input type='text' name='first'><br/> Last Name: <input type='text' name='last'><br/> Hours of Work: <input type='text' name='hours'><br/> Hourly Pay Rate: <input type='text' name='rate'><br/> <input type='submit' value='submit'> </form> </body> </html> Each status has a comment textarea.
How can I get it to alert what the user has typed in the textarea when the return key is pressed.
The textarea in the PHP loop is like this:
<textarea class='commentbox' id='" . $thisid . "'></textarea>The reason why I am asking this and not how to save it to the database etc is because I think I will be able to do that. Thanks, Apologies for this because it's probably very simple, but I've never worked with JavaScript or PHP or anything before.
So the website I am producing is to sell tickets for something. To purchase these tickets the user is required to click on the seats they want and it will pop up in a box on the left hand side confirming their seat selection and how much the ticket is.
The website has to feature a "Reset Database" button which totally resets everything. No tickets are selected anymore, the user is logged out etc. I have this working fine.
It also has to feature a "Cancel" button, which simply removes the seats the user has selected, but still keeps them logged in. How do I code this?
This is what the "Cancel" button looks like on the Index page:
<div id="theButtons"> <input type="button" value="Cancel Choices" title="Cancel Choices" onclick="cancel()" /> </div> And this is my code on the JavaScript page: function cancel(){ var s = document.getElementsByTagName('space'); window.location="index.php"; } How do I get this working? Edited by DavidD95, 08 November 2014 - 10:36 AM. Hi i currenlty have adrop box filled with companies so the user can select which company they woudl like services from but the default is currently 0 and is to selecvt all firms but im unsure how to do this. Current code: Code: [Select] <td>Taxi Firm</td><td> <select name="taxifirm"> <option value="0" selected>All Taxi Firms</option> <?php $sql = mysql_query("SELECT * FROM taxi_Firms"); while($row = mysql_fetch_array($sql)){ $uid = $row["Firm_ID"]; $username = $row["Firm_Name"]; echo '<option value="'.$uid.'">'.$username.'</option>' ; } ?> amny help is welcomed thanx Hi, i know this is probably very basic but i have been banging my head and looking for tuts. i have built a mysql php dropdown menu. all displays fine. now, how do i get the menu to actualy take me to a new url? the new url should be www.mysite.com/"menu selection" Code: [Select] <? include_once 'includes/db.php'; $result = mysql_query("select * from crimerate WHERE DISTRICT = 'Limpopo'", $con); if (!$result) { die('Invalid query: ' . mysql_error()); } $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $crime=$row["CRIME"]; $options.="<OPTION VALUE=\"$id\">$crime</option>"; } ?> <SELECT NAME=crime> <OPTION VALUE=0>Choose <?=$options?> </SELECT> helo i a newbie in php. i need some help regarding my system. i want my data from database to display in drop down menu form.anyone have idea how to do that? i really need some help. i have search all over and couldn't find any solution. any suggestions would be helpful I did search this up but all of them were lists.
I want to make a menu drop down like so....
Non-clicked...
Clicked...
The grey boxes would be images (unless it is easier to code them).
I am a complete noob so please don't use technical terms
Thanks
im fairly new to php so tend to do trial and error..... more error than trial tbh. im wondering if it is possible to get a drop down menu to fill from a mysql database and to arrange it alphabetically. i have created the menu just dont know how to arrange it better. also how can i use the items id in drop menu to load other info from that row on the database. hope you can help me. Code: [Select] <FORM> <?php $result = mysql_query( "SELECT * FROM movie_info" ) ; echo "<select name= film onChange='submit()' >film name</option>"; while ($nt=mysql_fetch_array($result)){ ?> <?php echo "<option value='$nt[id]'>$nt[title] </option>"; } ?> </select> </FORM> Hi I have a temporary web page with a drop down menu. Problem is to get rid of the gap on the drop down menus. Any help please
www.des-otoole.co.uk/top_menu
I'm trying to code a drop-down menu that has four options; one for pie,exp, root 3, and the golden ratio.(all math values) Beside the drop-down menu, there is an option for user-inputted data, they must input only positive numbers. I must take there selected drop-down menu option and times it by the user inputted number. I'm not sure how to check which option the user chose.
<form id="s" method="post"> </select> <input type="submit" name="Submit" value="Send"> Everything That ive tried has failed Okay, so, here's the scenario. I have a form that is editing an item that is already in the database. The text fields fill in just fine with that info. However, the drop down menus don't retrieve that info, rather resorting to the defaults, which can be a problem if you don't remember what you originally had. Is there anyway to make the dropdown menus pull the info from the table and use that rather than resorting back to the default? I tried using this: Code: [Select] <tr><td width="20%">Bonus:</td><td><select name="bonus" value="{{bonus}}"> <option value="Attack" {{bonus1select}}>Add to the attack power of weapon</option> <option value="Defense" {{bonus2select}}>Add to the defensive power of armor</option> <option value="None" {{bonus3select}}>No effect</option> </select><br /></td></tr> So, it's obvious the "value" portion not working. Any help would be great!! Hi, i wonder whether someone may be able to help me please. I am using a combination of PHP and AJAX to create two drop down menus on a HTML form. The data is being pulled from a mySQL database with the options available in the second drop down dependent on the value selected in the first. The initial drop down menu called 'detectors' and the behaviours for the second drop down menu, 'searchheads' are created with the following AJAX code: Code: [Select] Function AjaxFunction(detectorid) { var httpxml; try { // Firefox, Opera 8.0+, Safari httpxml=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { httpxml=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpxml=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } function stateck() { if(httpxml.readyState==4) { var myarray=eval(httpxml.responseText); // Before adding new we must remove previously loaded elements for(j=document.addfindstolocation.searchheads.options.length-1;j>=0;j--) { document.addfindstolocation.searchheads.remove(j); } for (i=0;i<myarray.length;i++) { var optn = document.createElement("OPTION"); optn.text = myarray[i]; optn.value = myarray[i]; document.addfindstolocation.searchheads.options.add(optn); } } } var url="searchheaddetails.php"; url=url+"?detectorid="+detectorid; url=url+"&sid="+Math.random(); httpxml.onreadystatechange=stateck; httpxml.open("GET",url,true); httpxml.send(null); } The following code is the file 'searchheaddetails.php' (as highlighted above) which populates the second drop down menu. Code: [Select] <? $detectorid=$_GET['detectorid']; require "config.php"; $q=mysql_query("SELECT * FROM searchheads WHERE detectorid='$detectorid' ORDER BY 'searchheadname' ASC"); echo mysql_error(); $myarray=array(); $str=""; while($nt=mysql_fetch_array($q)){ $str=$str . "\"$nt[searchheadname]\","; } $str=substr($str,0,(strLen($str)-1)); // Removing the last char , from the string echo "new Array($str)"; ?> And this is the section of my form that pulls together the two drop down menus. Code: [Select] <form name="addfindstolocation" method="post" id="addfindstolocation"> <div align="left"> <select name=detectors id="detectorid" onchange="AjaxFunction(this.value);"> <option value=''>Select One</option> <? require "phpfile.php";// connection to database $q=mysql_query("SELECT * from detectors WHERE userid='1'ORDER BY 'detectorname' ASC"); while($n=mysql_fetch_array($q)){ echo "<option value=$n[detectorid]>$n[detectorname]</option>"; } ?> </select> </div> </div> <p align="left"> <label></label> <label>Search Head Used</label></p> <div> <div align="left"> <select name=searchheads id="searchheadid"> </select> </div> The drop down menus work fine, but I'm having a little difficulty with the data that is being saved. For the 'detectors' drop down menu the data being saved upon a selection being made is the 'id' pertient to the relevant detector e.g. 'Detector1' is selected and the 'id' value of '1' is saved which is exactly what I want. However when it comes to the second drop down menu, the value saved is the text value that the user selects, rather than the 'id'. e.g. 'Deep Search Head ' rather than an 'id' of '1'. Could someone perhaps tell me please what I need to change so that the 'id' value is saved rather than the text value. If it helps, the coding is taken from the following http://www.plus2net.com/php_tutorial/ajax_drop_down_list.php. Many thanks and kind regards. Chris This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=310879.0 Hello, I have the following function function make_agent_drop($dropname,$parent=''){ $agents = mysql_query("SELECT * FROM ad_category WHERE cat_status='1' AND parent_id='".(is_numeric($parent)?$parent:"0")."'") or die(mysql_error()); $anum = mysql_num_rows($agents); if($anum>0){ $agentdrop='<select style="width:150px; height:20px; margin-left:100px; font-size:11px;" name="'.$dropname.'" id="'.$dropname.'" class="text" '.(is_numeric($parent)?'':'onchange="update_subcatdrop($(this).val());').'"> <option value="0">Select a Category</option>'; while($row= mysql_fetch_array($agents)){ $agentdrop.='<option value="'.$row['cat_id'].'">'.$row['cat_name'].'</option>'; } $agentdrop.='</select>'; }else{ $agentdrop= 'No '.(is_numeric($parent)?'Sub':'').'Categories Found.'; } return $agentdrop; ; } I creates a drop down from database cats and sub cats.. I am trying to figure out how to add a submit button to dynamically appear when it displays the sub category... Thanks! Dan Hello! This is my first post here. I'm usually do programming in Ruby (Rails) but for a special occasion I need PHP. So hi PHP people! I come in peace My question is quite simple. How do you make a drop down menu? Most preferably with database populated fields in it. In the Rails community, this really helped me make these menus in Rails: http://www.kahfei.com/?p=23 Could someone briefly write something like that too? (The place holders) Orrr you guys can just explain how to do it. The ones I found on the internet were quite confusing and not explained enough. Help anyone? Thank you I have lots of tables for my products could i use the table name for a drop down menu? or is it not safe Thanks for any help Hey guys im looking to do a drop down menu which is pretty basic however, in this drop down menu it uses an array of 4 values eg Orange, Apples, Bananas, Strawberry's. For this menu if a user has previously chosen an Orange which is stored on the db then then when the drop down menu is loaded it should move Orange to the top of the list, the same applies for the other values. How could I do this? I know how to do the select statement and place the values in an array. from there I dont know quite how to approach it. () Thank you. Hi, I'm no pro at PHP but I am trying to get a drop down menu to a authenticate before moving to the next part of the form. What I want is once a selection has been made, ONLY THEN can the user move on, OTHERWISE a message echo appears. This is the html menu box <select size="1" name="title"> <option>Please Select</option> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Dr">Dr</option> </select> Then this is what I have in the form PHP: $visitortitle = $_POST['visitortitle']; if ( HOW DO I GET THIS PART TO AUTHENTICATE AN OPTION HAS BEEN SELECTED? ) { echo "<p>Please enter a title correctly<br />before you try submitting the form again.</p>\n"; die ( '<a href="pef.html">click here go back and try again</a>' ); echo $id;} If anyone can help me sort out this part of the form I can move on as the rest is working fine? Thanks Gary I am trying to get the drop downs to work in this order on the second <li> 903,896,898,1513 but they won't. I think it's picking up ascending order maybe? Is there another php/include I should use? It's a WordPress site. Code: [Select] <div id="navigation"> <div id="navbar_menu"> <ul id="nav_menu"> <li><?php wp_list_pages('include=3&title_li=&depth=2');?></li> <li><?php wp_list_pages('include=2,903,896,898,1513&title_li=&depth=2');?></li> <li><?php wp_list_pages('include=23,911,913&title_li=&depth=1');?></li> <li><?php wp_list_pages('include=25,921,925,927&title_li=&depth=1');?></li> <li><?php wp_list_pages('include=27&title_li=&depth=2');?></li> <li><?php wp_list_categories('include=3&title_li=&depth=2');?></li> <li><?php wp_list_pages('include=407&title_li=&depth=2');?></li> </ul> </div> </div> Thanks in advance! [attachment deleted by admin] |