Tag Archives: select

Why does setSelected on JCheckBox lose effect?

Questions: Can someone explain to me why I lost the selection (set by setSelected()) for JCheckBox when I put the JOptionPane into the ItemListener? Is this a bug ? It is curious, that if this process is delayed with invokeLater(), setSelected() works correctly as I expected. from SSCCE import javax.swing.*; import java.awt.*; import java.awt.event.*; public… Read More »

Randomly select an item from a list

Questions: How can I randomly select an item from a list in java? eg. I have List<String> list = new ArrayList<String>(); list.add(“One”); list.add(“Two”); etc…. How can I randomly select from this list using the Random myRandomizer = new Random(); Answers: Something like this? Random randomizer = new Random(); String random = list.get(randomizer.nextInt(list.size())); Questions: Answers: Clean… Read More »

How to select a dropdown value in Selenium WebDriver using Java

Questions: am new to selenium , currently am working on selenium webdriver i want to select a value from the drop down. The id=periodId and the option is many in that am trying to select Last 52 weeks. Here is the Html tag: <select id=”periodId” name=”period” style=”display: none;”> <option value=”l4w”>Last 4 Weeks</option> <option value=”l52w”>Last 52… Read More »

How to select an item from a dropdown list using Selenium WebDriver with java?

Questions: How can I select an item from a drop down list like gender (eg male, female) using Selenium WebDriver with Java? I have tried this WebElement select = driver.findElement(By.id(“gender”)); List<WebElement> options = select.findElements(By.tagName(“Male”)); for (WebElement option : options) { if(“Germany”.equals(option.getText())) option.click(); } My above code didn’t work. Answers: Use – new Select(driver.findElement(By.id(“gender”))).selectByVisibleText(“Germany”); Of course,… Read More »

Laravel-5 how to populate select box from database with id value and name value

Questions: I want to create a select box like the one below using illuminate\html : <select> <option value=”$item->id”>$item->name</option> <option value=”$item->id”>$item->name</option> </select> In my controller I tried this: public function create() { $items = Items::all([‘id’, ‘name’]); return view(‘prices.create’, compact(‘id’, ‘items’)); } And in my view this: <div class=”form-group”> {!! Form::Label(‘item’, ‘Item:’) !!} {!! Form::select(‘item_id’, $items, null,… Read More »

mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\qcc\truckdelivery.php on line 9 no database selected

Questions: <?php require_once(‘Connections/connect.php’); ?> <?php $id_truck = mysql_real_escape_string($_GET[‘id_truck’]); $sql_PK = “SELECT * FROM tbl_truck WHERE id_truck = ‘{$id_truck}'”; $res_PK = mysql_query($sql_PK, $connect); $row_PK = mysql_fetch_assoc($res_PK); $truck_plate = $row_PK[‘truck_plate_no’]; $truck_plate = mysql_real_escape_string($truck_plate); $sql = “SELECT tbl_truck.truck_plate_no, tbl_delivery_details.delivery_details_route, tbl_delivery_details.delivery_details_destination, tbl_delivery_details.delivery_details_van_no, tbl_delivery_details.delivery_details_waybill_no, tbl_delivery_details.delivery_details_charge_invoice, tbl_delivery_details.delivery_details_revenue, tbl_delivery_details.delivery_details_strip_stuff, tbl_delivery_details.delivery_details_date FROM tbl_truck, tbl_delivery_details WHERE tbl_truck.truck_plate_no = tbl_delivery_details.tbl_truck_id_truck AND tbl_truck.truck_plate_no = ‘{$truck_plate}'”; $res… Read More »

Parse SELECT clause of SQL queries into a PHP array

Questions: This is more for analyzing a query in PHP BEFORE it’s sent to the server. Very complicated why im doing this, so i’d rather not go into the reason for this. In PHP, i need to store the field selections into a php array. So take this query for example: SELECT user_id,username,DATE(join_datetime) as join_date,… Read More »