drop down list default value - drop-down-menu

I'm trying to use a drop down list with a default value equals nothing
but nothing means zero and every time i try, it says that i cant divide by zero
how can i make the default value equal null not zero ?
<form method="post" action="try.php"name="test">
<select name="xx">
<option selected=""></option>
<option value="1">1</option>
<option value="3">3</option>
<option value="5">5</option>
<option value="7">7</option>
<option value="9">9</option>
</select>
<br /><input type="submit" name="submit" value="PROSES" />
</form>
<?php
if(isset($_POST['submit'])){
$x=$_POST['xx'];
$z=1/$x;
}
?>

Related

How to set a null value inside a drop-down selection without "parent_id" required

I would like to make a drop-down selection with the first selection comes with " NO PARENT ID REFERRED " and set as null value and pass into database in laravel
Here is my code
<div class="form-group">
<label for="bit_app_policy_category_parent">Parent Category</label>
<select id="bit_app_policy_category_parent" name="parent_id" class="form-control">
<option selected disabled>Please select one option</option>
#foreach($parents as $parent)
#if ($parent-> status != 'Freeze')
<option value="{{ $parent->id}}">{{$parent->description}} </option>
#endif
#endforeach
</select>
</div>
<div class="form-group">
<label for="bit_app_policy_category_status">Status<span class="required">*</span></label>
<select id="bit_app_policy_category_status" name="status" class="form-control">
<option value="Active">Active</option>
<option value="Freeze">Freeze</option>
</select>
</div>
Dropdown selection`
Expected result =
Please select one option
-----No parent ID referred-----(able to choose and pass value into db)
description 11 and so on .
PLEASE NOTE THAT IM UNABLE TO USE FORM METHOD AS MY LRAVEL UNABLE TO UPDATE DUDE TO SPECIFIC PURPOSES
try to add another <option> before foreach.
example codes:
<option value="null" selected>Please select one option</option>
#foreach($parents as $parent)
#if ($parent-> status != 'Freeze')
<option value="{{ $parent->id}}">{{$parent->description}} </option>
#endif
#endforeach
</select>
```

retrieving the max value of all the selects in a page with Xpath

I want to retrieve max value for each combobox present in a web page, with xpath.
Here is a sample HTML containing several combobox with choices:
<label> <span class="invisible_spoken">Some choice</span>
<select class="select_class">
<option value="0">0</option>
<option value="1" >
1
</option>
<option value="2" >
2
</option>
</select>
</label>
<label> <span class="invisible_spoken">Some choice</span>
<select class="select_class">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</label>
<label> <span class="invisible_spoken">Some choice</span>
<select class="select_class">
<option value="0">0</option>
<option value="1">1</option>
</select>
</label
What I would want to retrieve is the maximum value of each combobox, sample output :
2, 3, 1
I've tried with an expression like :
//table[#id="rooms"]//select[contains(#class, "b_selectbox")]/option[not(//table[#id="rooms"]//select[contains(#class, "b_selectbox")]/option/#value > #value)]/#value
But it is returning just combobox max values of the maximum combo value, in the sample case just 3 that is the highest, in the case there will be two combobox with maximum values equals to 3, then it will return those 2 ...
Xpath Selector for Options with highest value.
//label/select[#class="select_class123"]/option[not(../option/#value > #value)]
o/p: Option elements with highest values.
(//label/select[#class="select_class"]/option[not(../option/#value > #value)])/#value
o/p: 2, 3, 1
Test XML XPath online:
<select class="select_class">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<select class="select_class">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<select class="select_class">
<option value="0">0</option>
<option value="1">1</option>
</select>

How can i make custom form module joomla3.x

<select name="A">
<option value="1">Volvo</option>
<option value="2">Saab</option>
</select>
<select name="B">
<option value="1">test1</option>
<option value="2">test2</option>
</select>
<input type="Submit" >
After I submit, I want to show result from A and B. For example:
if($_POST['A']==1 && $_POST['B']==2){
echo 'true';
}else{
echo '0';
}
Is it possible to do this in joomla?
you have to enclosed this input fields into form tag. For example
<form method="post">
<select name="A">
<option value="1">Volvo</option>
<option value="2">Saab</option>
</select>
<select name="B">
<option value="1">test1</option>
<option value="2">test2</option>
</select>
<input type="Submit" >
</form>
Hope it will help

Watir-Webdriver - facing issue in selecting the date fields

I have a Date of Birth field in my application which does not have either of the usual identification elements like id, value, name etc. i am not sure how to identify these DOB elements and change the values of those. Could anyone help me on this.
Here's a full div portion of the HTML from the page where the DOB section is identified.
<div ng-class="{invalid:(fieldVM.$dirty || formController.$submitted) && fieldVM.$invalid}" class="jl-form-control ng-scope bday-select-input" label="Date of Birth" jl-validation-field="dateOfBirth">
<!-- ngIf: helperText -->
<div class="jl-label-wrapper">
<label for="joltForm-profileForm-dateOfBirth-input" id="joltForm-profileForm-dateOfBirth-labelStandard" ng-bind-html="label" class="jl-label ng-binding">Date of Birth</label>
<span class="jl-optional-text">(optional)</span>
</div>
<span class="error-icon"/>
<div class="inner-icon">
<input type="hidden" name="dateOfBirth" aria-required="true" required="required" id="joltForm-profileForm-dateOfBirth-input" ng-model="model.data.dateOfBirth" class="ng-pristine ng-untouched ng-invalid ng-invalid-required ng-invalid-sync-validate" tabindex="0" aria-invalid="true">
<div class="jl-layout-33-33-33">
<select jl-model="month" jl-change="checkChange(day, month, year)" jl-options="item for item in months" class="jl-select item jl-in ng-pristine ng-valid ng-touched" ng-options="item for item in months" ng-model="month" ng-change="checkChange(day, month, year)" tabindex="0" aria-invalid="false" style="transition-delay: -9999s;">
<option value="" class="" selected="selected">MM</option>
<option value="string:01" label="01">01</option>
<option value="string:02" label="02">02</option>
<option value="string:03" label="03">03</option>
<option value="string:04" label="04">04</option>
<option value="string:05" label="05">05</option>
<option value="string:06" label="06">06</option>
<option value="string:07" label="07">07</option>
<option value="string:08" label="08">08</option>
<option value="string:09" label="09">09</option>
<option value="number:10" label="10">10</option>
<option value="number:11" label="11">11</option>
<option value="number:12" label="12">12</option>
</select>
<select jl-model="day" jl-change="checkChange(day, month, year)" jl-options="item for item in days" class="jl-select item jl-in ng-pristine ng-untouched ng-valid" ng-options="item for item in days" ng-model="day" ng-change="checkChange(day, month, year)" tabindex="0" aria-invalid="false">
<option value="" class="" selected="selected">DD</option>
<option value="string:01" label="01">01</option>
<option value="string:02" label="02">02</option>
<option value="string:03" label="03">03</option>
<option value="string:04" label="04">04</option>
<option value="string:05" label="05">05</option>
<option value="string:06" label="06">06</option>
<option value="string:07" label="07">07</option>
<option value="string:08" label="08">08</option>
<option value="string:09" label="09">09</option>
<option value="number:10" label="10">10</option>
<option value="number:11" label="11">11</option>
<option value="number:12" label="12">12</option>
...
...
...
<option value="number:30" label="30">30</option>
<option value="number:31" label="31">31</option>
</select>
<select jl-model="year" jl-change="checkChange(day, month, year)" jl-options="item for item in years" class="jl-select item jl-in ng-pristine ng-untouched ng-valid" ng-options="item for item in years" ng-model="year" ng-change="checkChange(day, month, year)" tooltip="Required" tooltip-trigger="focus" tooltip-enable="(fieldVM.$dirty || formController.$submitted) && fieldVM.$invalid" tooltip-class="errorClass" tooltip-append-to-body="true" tabindex="0" aria-invalid="false">
<option value="" class="" selected="selected">YYYY</option>
<option value="number:1915" label="1915">1915</option>
<option value="number:1916" label="1916">1916</option>
...
...
...
<option value="number:2013" label="2013">2013</option>
<option value="number:2014" label="2014">2014</option>
<option value="number:2015" label="2015">2015</option>
</select>
</div>
</div>
<div class="help-block ng-binding"/>
</div>
Its an AngularJS web application.
The select elements look identifiable based on their ng-model attribute - which is "month", "day" and "year". You can locate elements using the ng-* attributes by using a CSS (or XPath) locator:
browser.select(css: 'select[ng-model="month"]').select('07')
browser.select(css: 'select[ng-model="day"]').select('31')
browser.select(css: 'select[ng-model="year"]').select('2014')
If you tend to use the ng-model a lot for identification, you should add it to the list of validate locators. This will save you from having to write CSS/XPath locators.
require 'watir-webdriver'
Watir::HTMLElement.attributes << :ng_model
browser.select(ng_model: 'month').select('07')
browser.select(ng_model: 'day').select('31')
browser.select(ng_model: 'year').select('2014')
Note that the above suggestions assume that there is only one set of month/day/year fields on the page. If there are multiple, you will need to be more specific in the locators. In this case, it looks like the encompassing div element has an identifiable class - "bday-select-input":
birthday = browser.div(class: 'bday-select-input')
birthday.select(css: 'select[ng-model="month"]').select('07')
birthday.select(css: 'select[ng-model="day"]').select('31')
birthday.select(css: 'select[ng-model="year"]').select('2014')

th:selected a number in a select/option with Thymeleaf doesn't work

I have this code
<div th:class="form-group">
<td><label class="control-label leftMargin10 rightMargin10" scope="col" th:text="#{insertHours.hhFrom}">Attivita'</label></td>
<td><select class="form-control" th:field="*{hhFrom}">
<option th:each="i : ${#numbers.sequence(0, 23)}" th:value="${i}" th:text="${i}" th:selected="${ i==9 } ">Options</option>
</select>
</td>
</div>
When I try to add a condition in th:selected it doesn't work.
I have also replaced with this code:
th:attr="${i==9}? selected=selected: '' "
but the result is the same.
The HTML
<select class="form-control" id="hhFrom" name="hhFrom">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
Thanks in advance to answers
You cannot use th:field along with th:selected.
If you replace th:field with name=someMeaningfullName the code will work just fine.
Check out this thread on the Thymeleaf forum for more information
Another hack that, is pretty simple and works, is to close the select tag: <select ... />
Please note /> at the end of first line:
<select th:field="*{percentage}" />
<option th:each="i : ${#numbers.sequence(0, 100)}" th:value="${i}" th:text="${i}" th:selected="${i==75}"></option>
</select>
Renders as:
<select id="percentage" name="percentage" />
<option value="0">0</option>
<option value="1">1</option>
...
<option value="74">74</option>
<option value="75" selected="selected">75</option>
<option value="76">76</option>
...
<option value="100">100</option>
</select>
Both web browser and Thymeleaf will handle this fine.
I used Thymeleaf v.3.0.9.RELEASE
Also I found out that if you put <div> tag around option fields, selected="selected" will also work. e.g
<select th:field="*{name}">
<div>
<option disabled="true" selected="selected" value="">Select</option>
<option value="1">first</option>
<option value="2">second</option>
</div>
</select>

Resources