Search the Community
Showing results for tags 'dropdown'.
-
Right now I have a mobile dropdown that works fine. The only issue I have is that when viewing it on my smartphone, the dropdown gets cut off at the bottom and I am unable to scroll it down to rest of it. Is there a way to fix it so that It's scrollable? Here's my js code of the dropdown. $(document).ready(function() { $(".nav-mobile li a").each(function() { if ($(this).next().length > 0) { $(this).addClass("parent-arrow"); } }) $(".toggle-mobile-menu").click(function(e) { e.preventDefault(); $(this).toggleClass("active-mobile"); $(".nav-mobile").toggle(); }); adjustMenu(); }); $(window).bind('resize orientationchange', function() { ww = document.body.clientWidth; adjustMenu(); }); var adjustMenu = function() { var ww = document.body.clientWidth; if (ww <= 850) { $(".toggle-mobile-menu").css("display", "block"); if (!$(".toggle-mobile-menu").hasClass("active-mobile")) { $(".nav-mobile").hide(); } else { $(".nav-mobile").show(); } $(".nav-mobile li").unbind('mouseenter mouseleave'); $(".nav-mobile li a.parent-arrow").unbind('click').bind('click', function(e) { // must be attached to anchor element to prevent bubbling e.preventDefault(); $(this).parent("li").toggleClass("hover"); }); } else if (ww > 850) { $(".toggle-mobile-menu").css("display", "none"); $(".nav-mobile").hide(); $(".nav-mobile li").removeClass("hover"); $(".nav-mobile li a").unbind('click'); $(".nav-mobile li").unbind('mouseenter mouseleave').bind('mouseenter mouseleave', function() { // must be attached to li so that mouseleave is not triggered when hover over submenu $(this).toggleClass('hover'); }); } }
-
I have a simple setup where I have a collapsed menu. When you click on the button, it will open a menu. If the menu is already opened and you open another menu, the previous menu will collapse. All that works. The only thing I noticed is that It will not collapse the opened menu if I click the same button. That menu will only collapse if I open a different menu. I was wondering how the code below will look with that extra function added? Here's the code for that. <h5 class="mobile-collapse__title">Title Button</h5> <div class="mobile-collapse__content"> <ul> <li>list 1</li> <li>list 2</li> <li>list 3</li> </ul> </div> <script> $(document).ready(function($){ $(".mobile-collapse__title").click(function(e) { e.preventDefault(); $('.mobile-collapse__content:visible').hide(); $(this).next('div.mobile-collapse__content').show(); }); }); </script>
-
Hi I'm using PHP for my Navigation Menu, My navbar is in a file named "home.php" looks like this: <ul class="nav navbar-nav navbar-right"> <li><a href="?page=home">Home</a></li> <li><a href="?page=about">About</a></li> <li><a href="?page=services">Services</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="?page=service2">Service 2</a></li> </ul> </ul> Then in my index.php: $page = $_GET['page']; if (!isset($page)) { include('home.php'); } if ($page == "home") { include('home.php'); } if ($page == "about") { include('about.php'); } if ($page == "services") { include('services.php'); } if ($page == "service2") { include('service2.php'); } It all works how I want it to except for one thing; I'd like to add; <li class="active"> To the page that is currently being viewed. How can I do this? Thank you in advance.
-
Unfortunately my ideas out pace my skills. I have a database that I would like certain people to access their own info, but nobody else's. It's not super sensitive info and won't mean much to anyone other than the end user but we don't like the idea of others accessing it so we'd like to put some protection on it. What I was hoping for is a dropdown list (there's about 30 or so clients that would be in a mysql table) where they can pick out their name, then text box for the password. When they hit submit button it would lead them to their own page with a table and their own info from a mysql table. I can get each one of these details to work separately, but I'm having trouble putting them all together (the password is where things get muddled). Can anyone point me to a place where they've already figured this out? Thanks!
-
I'm building a form for an organisation that organises a workshop for teenagers. There is an option to bring one or both parents to the workshop. So for each parent, there's a dropbox to answer the question "Will you participate in the workshop as well?" Depending if one, both or no parents will join, the user will be redirected to a different url after submiting (submit is always in the same place). The form is built with chronoforms in Joomla. This is the code for the dropdowns, please note that I can't change the values "Ja" or "Nee" because these option values are also sent to an exterior, custom made program so i'm not allowed to change it. Code for the dropdowns: <select class="cf_inputbox validate-selection required" id="select_17" size="1" title="verplicht veld" name="oudersessieouder1" style="width: 193px;"> <option value="">Make your choice</option> <option value="Ja">Yes, will participate</option> <option value="Nee">No, will not participate</option> </select><label class="cf_label" style="width: 150px;"> Will this parent join the workshop?</label> <select class="cf_inputbox validate-selection required" id="select_18" size="1" title="verplicht veld" name="oudersessieouder2" style="width: 193px;"> <option value="">Make your choice</option> <option value="Ja">Yes, will participate</option> <option value="Nee">No, will not participate</option> </select><label class="cf_label" style="width: 150px;"> Will this parent join the workshop?</label> And this is the after submitting, here I can write the code to redirect depending on the values of the previous two dropdowns: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>bedankt</title> </head> <body> <script> if (one parent comes, so one of the 2 dropdown values will be "Ja") window.location.replace("http://www.website.be/inschrijven-pe-jongeren-1-parent.html") else if (both parents come, so both dropdown values will be "Ja") window.location.replace("http://www.website.be/inschrijven-pe-jongeren-both-parents.html") else window.location="http://www.website.be/inschrijven-pe-jongeren.html" </script> <p align="center"> </p> </body> </html>
- 5 replies
-
- chronoforms
- redirect
-
(and 3 more)
Tagged with:
-
Keep getting these two errors when trying to UPDATE a field called "type" to 'banana' based on the fuitid. Why is this happening? Undefined index: fruitid in update.php You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 <form method="POST" action="update.php"> <select> <option value="">Select</option> <?php $sql = "SELECT fruitid, datefrom, dateto FROM fruits"; $sqlresult = $link->query($sql); $sqllist = array(); while($row = mysqli_fetch_array($sqlresult)) { echo "<option>".$row['datefrom']." - ".$row['dateto']."</option>"; } ?> </select> <input type="hidden" value="<?php echo $fruitid;?>" name="fruitid"/> <input type="submit" value="Submit" name="submit"/> </form> <?php if(isset($_POST['submit'])) { $fruitid= mysqli_real_escape_string($link,$_POST['fruitid']); $sql = "UPDATE `fruits` SET `type`='banana' WHERE fruitid = $fruitid"; if (mysqli_query($link, $sql)) { echo "updated"; } else { echo "problem: " . mysqli_error($link); } } ?>
-
Hi. I have 2 problems which I'm hopeing someone can help me with. 1. For the following script to change the pages language, I would like it so that whichever option selected is set on the page (i.e. if you select Euskal, the select box stays set as Euskal, and not Espanyol as it does at the moment) <form name="Language" action="" method="post" id="Language"> <div class="btn-group"> <?php $uri = strtok($_SERVER["REQUEST_URI"],'?');; $url="http://".$_SERVER['HTTP_HOST'].$uri; ?> <span class="btn btn-primary"> <select name="lang" onchange="javascript:change_langs(this.form)"> <option value="Esp">Espanyol</option> <option value="Eng">English</option> <option value="Cat">Catalan</option> <option value="Bas">Euskal</option> <option value="Gal">Galego</option> </select> </span> </div></form> 2. I have 2 dropdown lists in the following format: <select class="form-control" name='category'> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="A"))?"selected='A'":""); ?> value='A'><?=getlg($lang,"A")?></option> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="b"))?"selected='b'":""); ?> value='b'><?=getlg($lang,"b")?></option> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="c"))?"selected='c'":""); ?> value='c'><?=getlg($lang,"c")?></option> </select> <select class="form-control" name='category'> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="D"))?"selected='D'":""); ?> value='D'><?=getlg($lang,"D")?></option> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="e"))?"selected='e'":""); ?> value='e'><?=getlg($lang,"e")?></option> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="f"))?"selected='f'":""); ?> value='f'><?=getlg($lang,"f")?></option> </select> However, I require just one dropdown list with catagories A and D as the main item. Catagories b & c should be a sub category of A, and e & f should be a sub category of D Any help would be appreciated. Thanks
-
i am new to web designing, i don't know much about javascript. <select id="plan" align="center" valign="center"> <option value="images/21.jpg">PHASE 1</option> <option value="images/22.jpg">PHASE 2</option> <option value="images/23.jpg">PHASE 3</option> <option value="images/24.jpg">PHASE 4</option> <option value="images/25.jpg">PHASE 5</option> <option value="images/200.jpg">PHASE 6</option> <option value="images/210.jpg">PHASE 7</option> </select> <img id="image" src="images/21.jpg" align="center" valign="center" Onclick="zoom"/> <script type="text/javascript"> function setplan() { var img = document.getElementById("image"); img.src = this.value; return false; } document.getElementById("plan").onchange = setplan; </script> above is the code given. the above codes changes the images when the values of the dropdown menu are selected, every dropdown menu has a specific image bind to it. when the image is displayed after selecting any item from dropdown, now i want to popup or zoom the image or open it itnto new widow when i click on the image, plz help me. http://gdcindia.co.in/SAI%20SHOBHAN.html plz visit this link, and go to 2nd tab floor plan. then u will know what i want plz help me.
- 1 reply
-
- javascript
- dropdown
-
(and 3 more)
Tagged with:
-
for starters, i am a complete beginner at PHP, so i know almost nothing. so, the basic outline is that i am required to create a table with 2 columns, and use PHP where i can so the first set of code lays down the table and the ability to type in text of "name" and "surname". ----i think this "input" is HTML, yes?? is there a way to enter it as PHP? <table border=\"2\"> <tr><th><b>Requirements</b></th><th><b>Selections</b></th></tr> <tr><td>Name</td><td><input type="text" name="name"/></td></tr> <tr><td>Surname</td><td><input type="text" name="surname"/></td></tr> so, for this next section, adding on is the part for "age". i want this to appear as a dropdown selection. i've written PHP where possible, however this does not work when opening the file in a browser. it simply leaves a blank dropdown menu with no options. ???? <tr><td>Age</td><td><select> <?php for ($num=11; $num<=22; $num++){ echo '<option>' .$num. '</option>'; } ?> </select> lastly, i have the part for "activity choice". this again i believe i wrote the radio buttons in HTML??? am i able to write this as PHP???? <tr><td>Activity Choice</td><td><input type="radio" name="activityChoice" value "music"/> Music ($30.00)<br> <input type="radio" name="activityChoice" value "swimming"/> Swimming ($25.50)<br> <input type="radio" name="activityChoice" value "tennis"/> Tennis ($20.00)<br> <input type="radio" name="activityChoice" value "basketball"/> Basketball ($15.50)<br> <input type="radio" name="activityChoice" value "netball"/> Netball ($15.50)<br> <input type="radio" name="activityChoice" value "dance"/> Dance ($10.50)<br> <input type="radio" name="activityChoice" value "communityService"/> Community Service (No Charge)</td></tr> please please please help??
-
Hopefully someone can help, firstly i am a newbie at php coding but keen to learn more. Here is my problem The database is built correctly with all the information i need, the first part is the dropdown menu which you select a car, next you choose a month and mileage - from there it shall show you the correct price for each one. There is columns for each price, mileage and months i just need to figure out how best to start this thing. I first started by this $query = "SELECT DISTINCT Full_Description FROM import"; $result = mysql_query($query) or die(mysql_error()); echo "<select name=\"carname\">"; echo '<option value="">Please select...</option>'; while($row = mysql_fetch_array($result)) echo "<option value='{$row['id']}'>{$row['Full_Description']}</option>"; echo "</select>"; $carids = $_POST["carname"]; $_SESSION["carid"] = $package_id; echo $_SESSION["carid"]; $query2 = "SELECT Mileage FROM import WHERE id = '$carnames22'"; $resultsdsd = mysql_query($query2) or die(mysql_error()); ?> This got me all the cars listed in a dropdown select, but it did not store the selected car id for me to use else where, i am not even sure if this is the best approach. Please can some help me! Jay
-
Normally you can get input names from form using $_GET method. However, with a multi level dropdown, the php query files are called externally and through the js code. So I am wondering, what is the best way to get the input names of each dropdown? For eg. country, state, city. Getting the input name for the country is easy; how would I get it for the state and city if they are in a seperate php files? Do I get the input name in their own files and put them in a session?
-
I was following a tutorial from else where that showed how to do dynamic dropdown with ajax. Unfortunatly he only does it for two drop downs. I need a third dropdown. I have a dropdown for select country and select region. They work great. How can I add the select city dropdown as well with js? js code on index.php <html> <head> <script> function showHint(str) { var xmlhttp; if (str.length==0) { document.getElementById("regiondiv").innerHTML=""; return; } if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("regiondiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","geo.php?country="+str,true); xmlhttp.send(null); } </script> </head> <body> <div class="field"> <label for="cat">Country</label> <select id="country" name="country" onChange="showHint(this.value);" required > <option value="0">--Select Country--</option> <?php $getCountry = DB::getInstance()->query("SELECT * FROM countries"); if(!$getCountry->count()) { echo 'No Country found!'; } else { foreach($getCountry->results() as $row) { $country_id = escape($row->countryId); $country_name = escape($row->countryName); ?><option value="<?php echo $country_id; ?>" ><?php echo $country_name; ?></option><?php } } ?> </select> </div> <label for="cat">Region</label> <div id="regiondiv"> <select name="region" id="region"> <option>--Select State--</option> <option></option> </div> </body> </html> ajax.php <?php require_once 'core/init.php'; $country_id = escape(Input::get('country')); $select_region = DB::getInstance()->get('regions', array('countryId', '=', $country_id)); if(!$select_region->count()) { echo 'No Country found!'; } else { ?><select name="region" id="region"><?php foreach($select_region->results() as $row) { $region_id = escape($row->regionId); $region_name = escape($row->regionName); ?><option value="<?php echo $region_id; ?>" ><?php echo $region_name; ?></option><?php } ?></select><?php }
-
hi,,, i need question about populate table based on dropdown this my php file kecamatan.php <?php require 'config_db.php'; $self='kelurahan.php'; if (isset($_POST['action'])&&$_POST['action']=='edit'){ $namakelurahan = _post('namakelurahan'); if ($namakelurahan==''){ r2($self,'e','Nama kelurahan tidak boleh kosong'); } $id = _post('id'); $grp = ORM::for_table('kelurahan')->find_one($id); $grp->set('namakelurahan', $namakelurahan); $grp->save(); r2($self,'s','Perubahan data berhasil di lakukan'); } elseif (isset($_POST['action'])&&$_POST['action']=='delete'){ $trid = _post('trid'); $tr = ORM::for_table('kelurahan')->find_one($trid); if (!$tr){ r2($self,'e','Nama kelurahan tidak di temukan'); } $tr->delete(); r2($self,'s','Data berhasil di hapus'); } elseif (isset($_POST['action'])&&$_POST['action']=='add'){ $namakelurahan = _post('kelurahan'); if ($namakelurahan==''){ r2($self,'e','Nama kelurahan wajib diisi'); } $grp = ORM::for_table('kelurahan')->create(); $grp->namakelurahan=$namakelurahan; $grp->save(); r2($self,'s','kelurahan berhasil disimpan'); } else {?> <?php $query ="SELECT * from kecamatan"; $stmt = $dbh->prepare("$query"); $stmt->execute(); $reskecamatan = $stmt->fetchAll(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><?php echo 'Sistem Informasi Surveilans' // lc('WebsiteTitle'); ?></title> <link rel="shortcut icon" type="image/x-icon" href="../assets/img/favicon.ico"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link type='text/css' href='views/bmsapp/css/cstyle.css' rel='stylesheet' /> <link href="../assets/css/bootstrap.min.css" rel="stylesheet"> <link href="../assets/css/bootstrap-responsive.min.css" rel="stylesheet"> <link href="../assets/css/clientstyle.css" rel="stylesheet"> <link href="../assets/css/common.css" rel="stylesheet" type="text/css" /> </head> <body style='background-color: #FBFBFB;'> <div id='main-container'> <div class='header'> <div class="header-box wrapper"> <div class="hd-logo"><a href="#"><img src="../assets/uploads/logo.png" alt="Logo"/></a></div> </div> </div> <div class="navbar"> <?php include 'menu.php';?> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <h3>Data kelurahan</h6> <table> <tr> <td> Kecamatan : <select onchange=""> <option value="-1">Semua Kecamatan</option> <?php foreach($reskecamatan as $allkecamatan) { $id = $allkecamatan['id']; $namakecamatan = $allkecamatan['namakecamatan']; ?> <option value="<?php echo $allkecamatan['id']?> "> <?php echo $allkecamatan['namakecamatan']; ?> </option> <?php } ?> </select> </td> </tr> </table> <table class="table table-bordered table-striped table-hover"> <tr> <th scope="col">No</th> <th scope="col" style="display:none;">Id kelurahan</th> <th scope="col">Nama kelurahan</th> <th scope="col">Nama Kecamatan</th> <th scope="col">Olah Data <img id="ajxspin" src='../assets/img/blue_spinner.gif'/></th> </tr> <?php $query ="SELECT kelurahan.id, kelurahan.idkecamatan, kecamatan.namakecamatan, kelurahan.namakelurahan FROM kecamatan INNER JOIN kelurahan ON kelurahan.idkecamatan = kecamatan.id"; $stmt = $dbh->prepare("$query"); $stmt->execute(); $result = $stmt->fetchAll(); $i='0'; foreach($result as $accgroup) { $i++; $id = $accgroup['id']; $namakelurahan = $accgroup['namakelurahan']; $namakecamatan = $accgroup['namakecamatan']; echo "<tr> <td>$i</td> <td style=\"display:none;\">$id</td> <td>$namakelurahan</td> <td>$namakecamatan</td> <td><a href=\"kelurahan.edit.php?_cmd=$id\" data-toggle=\"modal\"><i class=\"icon-pencil\"></i></a> <a href=\"kelurahan.delete.php?_cmd=$id\" data-toggle=\"modal\"><i class=\"icon-remove\"></i></a></td> </tr>";} ?> <tr> <!--td colspan="3"><a class="btn btn-inverse" href="my-tickets.php"><?php echo 'view' ?> <?php echo 'all_support_tickets' ?></a> <a class="btn btn-primary" href="create-ticket.php"><?php echo 'new_ticket' ?></a></td--> <td colspan="4"> <a class="btn btn-inverse" href="kelurahan.add.php" data-toggle="modal" ><i class="icon-plus icon-white"></i>Tambah Data</a> <a class="btn btn-primary" href="kelurahan.lap.php"><i class="icon-list icon-white"></i>Laporan</a> </td> </tr> </table> </div> </div> </div> </div> </div> <div class="footer"><?php echo $footerTxt; ?><br /><br /></div> </body> </html> <?php } ?> and this output my code in browser: and my question, how to populate the table based on selected dropdown value? sorry my english is bad thanks b4
-
hello i have a dropdown box where i have populated values from the sql database. no when i select a value from the drop dopwn, i want to display all the records related to that value under the dropdown. here is my code <?php $select=FALSE; require_once ("configFile.php"); $result=mysql_query("SELECT Registration_No FROM vehicle_master "); if($result == FALSE) { die(mysql_error()); // TODO: better error handling } //populate dropdown with vehicles //echo "<label>Select vehicle number : </label>"; //echo "<select name='vehicles'>"; //while ($row = mysql_fetch_array($result)) //{ // echo "<option value='numberPlate'>" . $row['Registration_No'] . "</option>"; //} //echo "</select>"; //echo "<br><br>"; // $select=isset($_POST['vehicles']); ?> <form id="form1" name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <?php echo "<select name='select'>"; $list=mysql_query("SELECT * from vehicle_master"); while($row_list=mysql_fetch_assoc($list)) { ?> <option value="<?php echo $row_list['Registration_No']; ?>" <?php if($row_list['Registration_No']==$select) { echo "selected"; } ?>> <?php echo $row_list['Registration_No']; ?> </option> <?php } ?> </select> <input type="submit" name="Submit" value="select" /> </form> <br> <?php if (isset($_POST['SELECT'])) { $Registration_Nos=mysql_real_escape_string($_POST['SELECT']); $result=mysql_query("SELECT * FROM vehicle_master WHERE Registration_No='".$Registration_Nos."'"); while ($row=mysql_fetch_assoc($result)) { echo "".$row['Emergency_Contact_1'].""; } }?>. can anyone tell me where am i going wrong ? control.php
-
Can anyone help me please? I am trying to populate my page with data that is filtered from the dropdown box. It can either be "onchange" or clicking a button, not too fussed on this. I have tried so many ways but getting more and more lost an confused and ended up with nothing at all. I have stripped the coding back to where it last worked so any help is appreciated. <body> <table width="680" border="0" align="center" cellpadding="4" cellspacing="0"> <tr> <td> </td> </tr> <tr><td class="text-heading"><p>Financial Services Guides and Adviser Profiles</p><p class="Text_Heading_Black1">PAGE STILL IN DEVELOPMENT</p> <form id="form1" name="form1" method="post" action=""> <span class="text-questions">Adviser: </span> <select name="advselect" id="advselect"> <option value=" " selected="selected"> </option> <?php require ('../edb.php'); if (!$con) { die("MySQL could not connect!"); } $result= mysql_query("SELECT id, LastName, FirstName, UserType FROM `eusers` WHERE UserType='ADV' or UserType='STF' ORDER by LastName ASC"); while ($row = mysql_fetch_array($result)){ echo '<option value="'. $row['id'] .'">'. $row['LastName'] .', '. $row['FirstName'] .'</option>'; } ?> </select> <input type="submit" name="advselect" id="advselect" value="Filter / View" /> </form></td> </tr> <tr><td><p class="Text_SubHeading">Current Version </p> <table width="650" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="150">Adviser</td> <td width="200">Document</td> <td width="100">Version</td> <td width="50">Current</td> <td width="50">View</td> </tr> <?php include("../edb.php"); $data=mysql_query("SELECT * FROM `adocs_fsg_profile` INNER JOIN `eusers` ON eusers.id = adocs_fsg_profile.AdviserCode WHERE Current='Y' and ORDER BY LastName ASC, FirstName ASC, DocName ASC, DateUploaded DESC"); while($test = mysql_fetch_array($data)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td class='text-questions'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='text-questions'>".$test['DocName']."</td>"; echo"<td class='text-questions'>".$test['Version']."</td>"; echo"<td class='text-questions'>".$test['Current']."</td>"; echo"<td><a class='".$test['cssclass']."'href =".$test['URL'].">".$test['ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> </table> <p class="Text_SubHeading">Previous Versions </p> <table width="650" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="150">Adviser</td> <td width="200">Document</td> <td width="100">Version</td> <td width="50">Current</td> <td width="50">View</td> </tr> <?php include("../edb.php"); $data=mysql_query("SELECT * FROM `adocs_fsg_profile` INNER JOIN `eusers` ON eusers.id = adocs_fsg_profile.AdviserCode WHERE Current='N' ORDER BY LastName ASC, FirstName ASC, DocName ASC, DateUploaded DESC"); while($test = mysql_fetch_array($data)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td class='text-questions'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='text-questions'>".$test['DocName']."</td>"; echo"<td class='text-questions'>".$test['Version']."</td>"; echo"<td class='text-questions'>".$test['Current']."</td>"; echo"<td><a class='".$test['cssclass']."'href =".$test['URL'].">".$test['ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> </table></td> </tr> </table> </body>
-
Hi. Sorry if I've posted in the wrong forum or something - I joined this forum a few seconds ago. I'm trying to create something which displays all of the users in a database table in a drop-down menu. I've tried this code: <?php include 'config.php'; session_start(); $suser = $_SESSION['user']; $con = mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']); mysql_select_db($config['database']); $cpuTable = $config['cpuTable']; $query = mysql_query("SELECT * FROM $cpuTable WHERE suser='$suser'"); while($row = mysql_fetch_assoc($qa)) { $users = $row['username']; echo " <select name='cpuser'> <option value='user'>$users</option> </select>"; } I created two users in the database - "cp_test1" and "cp_test2", tried the code and it outputted this: Instead of listing the users in one drop-down menu, it creates two and lists one in each. Can anyone help? Thanks
-
Hello I was wondering how could i autofill a form based on a drop down list using raw php and mysql . I know that the connection to database would have to be established but what next ? Any Pointers would be helpful Also check the attached photo to maybe understand more than I'm explaining
-
I am developing php page, I am struck on one part :banghead: I have 3 dropdown menus. 1) Room Type 2) No of Person 3) Extra Person and a Textbox Now my Issue is, When I select Room type as Executive the amount should be shown on textbox and select "premium" relevant amount should be shown. when I add Extra Person, Rs 500 should be added in textbox. Thanks shamil
-
I need some assistance changing a single select into a multiple select form drop-down. I am having issues with the multiple selections storing. Thank you for your help! $var = " <script type='text/javascript'> jQuery(function(){ jQuery('form').attr('method', 'get'); jQuery('form').after('<input type=\"submit\" id=\"doaction_k2\" class=\"button-secondary action\" value=\"Apply Folder Access\" style=\"background: red; color: #fff;\">'); var thisurl = ''; var thaturl = ''; jQuery('#doaction_k2').live('click', function(){ jQuery('.new_file_access').each(function(){ thisurl = thisurl + '|' + jQuery(this).attr('userid') + '~' + jQuery(this).val(); }); jQuery('.new_file_readwrite').each(function(){ thaturl = thaturl + '|' + jQuery(this).attr('userid') + '~' + jQuery(this).val(); }); jQuery.post(document.URL, { update_access: 1, file_access: thisurl, file_readwrite: thaturl }, function(){ window.location = document.URL; }); return false; }); }); </script>"; } $var .= "<select multiple='yes' id='file_manager_accessk".$user_id."[]' class='new_file_access' userid='$user_id'><option value='' $noaccess>No Access</option>"; foreach($ACCESS_ARRAY as $key=>$value) { $key = str_replace('\\', '/', $key); $keys = $key .'~'. $urls.'/'.$value; $keys = substr($keys, 0, strlen($keys)-1); $keys1 = base64_encode($keys); $var .= "<option value='$keys1' $select[$keys]>$value</option>"; } $var .= "</select>"; return $var; ~ Sarah
-
Grab the value from the dropdown list and check against ...
halben posted a topic in PHP Coding Help
Hello Guys/Gals, I'm trying to get a drop down list name "SomeAccount" and get a value from the list which is "Partner." I don't this this is the right way to do it but can someone please help me? $someRole = $some_client -> getID($userId, array('SomeAccount' => 'Partner')); After assigning the variable, I want to check against a $_Post['role'] to see if $someRole == $_Post['role']. if ($someRole == $_Post['role'] == 'subscriber') { update_something(); } Thanks, Halben -
Hello everyone, this is my first post..jeje I've a problem with a simple dropdown, the dropdown is populated with mysql table, and everything works fine, but when I use the submit button, in the save.php doesn't get the first choice of the dropdown! if I select 2nd o 3rd or other..it works..but when I choose the first it return empty.. here my code: EDIT.PHP <div class="form-row row-fluid"> <label class="form-label span4" for="tipoproveedor">Tipo Proveedor</label> <div class="span7 controls"> <select name="selectTipoProveedor" id="selectTipoProveedor"> <option VALUE=<? while ($rowTipoProveedor=mysql_fetch_array($resultTipoProveedor)){ if($rowTipoProveedor['ClaTipoProveedor'] == $row->ClaTipoProveedor) echo '<option selected="selected" value='.$rowTipoProveedor['ClaTipoProveedor'].'>' .$rowTipoProveedor['NomTipoProveedor']. '</option>'; else echo'<option value='.$rowTipoProveedor['ClaTipoProveedor'].'>'.$rowTipoProveedor['NomTipoProveedor'].'</option>'; }?> </option> </select> </div> </div> SAVE.PHP .... $tipoprov = $_POST[selectTipoProveedor]; $test = "<h2 class=>".$tipoprov."</h2>"; ... Thanks in advance!
-
Not sure how to go about this task but I imagine it requires some sort of foreach loop I have a drop down list populated by a label called LST_Type, this table only exists to provide options for this dropdown list The value selected on the dropdown menu gets written to a table called "assets". when the users clicks away from the form (using ajax) Here is what I need to happen: On page load the dropdown list need its default option to be whatever the current value of the record is in the "asset" table. As the only way you can insert data into this field is via the dropdown list it will always be somethig from the "LST_Type" table The reason is that the data is written to the fields when you click away from the input boxes and unless you are editing the "Type" record it updates it to its default selection. hope this makes sense here is my code: <tr id="<?php echo $id; ?>" class="edit_tr"> <!-- Title Colum --><td class="style4" style="font-size:14px;width:200; height:35px; class="edit_td"> Type: </td> <td style="font-size:14px;width:270px;border:solid 0px #000;padding:0px; class="edit_td"> <span style="color:#0066CC;" id="type1_<?php echo $id; ?>" class="text"><?php echo $Type; ?></span> <!-- ***************************************START - This Is the dropdown menu script *********************************************** --> <script type="text/javascript"> function OnDropDownChange2(dropDown) { var selectedValue = dropDown.options[dropDown.selectedIndex].value; document.getElementById("type1_input_<?php echo $id; ?>").value = selectedValue; } </script> <select name = "MYtype" id="type1_input_<?php echo $id; ?>" class="editbox" onChange="OnDropDownChange2(this);">> <?php $sql = mysql_query("SELECT Type FROM LST_Type"); while ($row = mysql_fetch_array($sql)){ echo "<option value='" . $row['Type'] . "'>" . $row['Type'] . "</option>"; } ?> </select> <input type="text" value="<?php echo $Type; ?>" class="editbox" id="type1_input_<?php echo $id; ?>" /> /> <!-- ***************************************END *********************************************** -->
-
I have a program with 3 select statements, each of which will be populated based on the selected value of the previous one. but for some reason it's not working, and I am tearing my hair out trying to figure out what I am doing wrong. The values of the selects are blank when the page loads, I have a script that detects the page has loaded, and this calls a task that populates the first dropdown. This works fine. I have a script that follows this which detects a change in the selected value of the first dropdown and is supposed to call a task to populate the second dropdown. This does not trigger at all. The only way I can get it to trigger is if I comment out the first script (initial load). I'm sure it's something simple, but for my simple mind (when it comes to JS at least) it's proving an impossible task, and I'm all Googled out. The input form code is as follows: <form method="POST" id="Form1" name="Form1" action="TIMINGTOOL.pgm?task=dspitems"> <span id="first-choice-code"> <select id='first-choice'> <option value='null'>Select A Manufacturer</option> </select> </span> <br> <span id="second-choice-code"> <select id='second-choice'> <option value='null'></option> </select> </span> <br> <span id="third-choice-code"> <select id='third-choice'> <option value='null'></option> </select> </span> <br> <div id="FirstError" style="color:red"></div> <div id="SecondError" style="color:red"></div> <div id="ThirdError" style="color:red"></div> <input type="image" src="images/GO_Up.gif" name="Go1" border="0" align="absbottom" id="Go1" /> </form> The scripts (which are just above the page footer) are as follows: <script> // Populate First Select On Page Load $(window).load(function(){ $.get("TIMINGTOOL.pgm?task=first" , function(data) { $("#first-choice-code").html(data); }); alert("select loaded"); }); </script> //script> // Populate Second Select On First Change //$("#first-choice").change(function() { // $.get("TIMINGTOOL.pgm?task=second&choice="+$("#first-choice").val() , function(data) { // $("#second-choice-code").html(data); //}); //}); ///script> <script> // Populate Second Select On First Change $("#first-choice").change(function(){ alert("The new value is: " + $(this).val()); }); </script> The "real" second script has been commented out in the above code, and replaced by one that detects a change in the dropdown and displays an alert. The first script is also set to display an alert so I can tell which is triggered. Any thoughts please. I know it could probably be coded better, but I am trying to keep it simpler based on my limited knowledge of Javascript and my even more limited knowledge of Jquery. Thanks in advance.
-
I have a function that builds an array an works great. Form <?php $name = 'logWeather'; $options = array( 'Fair', 'Windy', 'Rainy','Stormy'); $selected = $logWeather; echo dropdown( $name, $options, $selected ); ?> Function <?php function dropdown( $name, array $options, $selected) { /*** begin the select ***/ $dropdown = '<select name="'.$name.'" id="'.$name.'">'."\n"; $selected = $selected; /*** loop over the options ***/ foreach( $options as $key=>$option ) { /*** assign a selected value ***/ $select = $selected==$key ? ' selected' : null; /*** add each option to the dropdown ***/ $dropdown .= '<option value="'.$key.'"'.$select.'>'.$option.'</option>'."\n"; } /*** close the select ***/ $dropdown .= '</select>'."\n"; /*** and return the completed dropdown ***/ return $dropdown; } ?> This works perfectly to edit a dropdown built from an array, but I am trying to add in a little more functionality. How can I add in a hidden value and a displayed value ex in html <select name="logSeaCondition"> <option value="1">0-1 feet</option> <option value="4">2-4 feet</option> <option value="7">5-7 feet</option> <option value="10">8-10 feet</option> <option value="13">11-13 feet</option> <option value="16">14-16 feet</option> <option value="19">17-19 feet</option> <option value="21">20+ feet</option> </select> Can I possibly pass in an associative array and use value as key and echo the item in the array?