Hey everyone i have this option menu where you can choose between Day 1, 2 and 3 and once the submit button is clicked it triggers a controller which saves the data to phpmyadmin. The data is being saved okay. But the option menu keeps resetting to day 1 no matter what option is clicked.
<div class="form-group row">
<label class="col-md-4 col-form-label text-md-right" for="choose-day">Choose a Day:</label>
<div class="col-md-6">
<select class="form-control" name="days" id="days-option">
<option class="form-control" value="1">Day 1</option>
<option class="form-control" value="2">Day 2</option>
<option class="form-control" value="3">Day 3</option>
</select>
</div>
Because the form is posted you need to store the value and then add the selected statement to the option that has been chosen. ✌️
Note: your php post script should be running before the if($whatDay == 1) selected else the $whatDay doesn't have a value to use and it doesn't add selected to anything.
<?php
if (isset($_POST['post_Btn'])) {
$whatDay = $_POST['days'];
}
?>
<div class="form-group row">
<label class="col-md-4 col-form-label text-md-right" for="choose-day">Choose a Day:</label>
<div class="col-md-6">
<select class="form-control" name="days" id="days-option">
<option class="form-control" value="1" <?php if($whatDay == 1) { echo 'selected';} ?> >Day 1</option>
<option class="form-control" value="2" <?php if($whatDay == 2) { echo 'selected';} ?> >Day 2</option>
<option class="form-control" value="3" <?php if($whatDay == 3) { echo 'selected';} ?> >Day 3</option>
</select>
</div>
Related
I want to update values into dropdown list but when I click in the form the value change to null.
knowing that the add works correctly . Anyone can help me please ?
this is my html code:
<div class="form-group">
<label for="service">Service</label>
<select id="service" class="form-control" ngModel="{{editPersonne?.service}}" name="serviceId">
<option value="">Service</option>
<option value="service.id" *ngFor="let service of services" >{{service.designation}}</option>
</select>
</div>
you should use varibale
<div class="form-group">
<label for="service">Service</label>
<select id="service" class="form-control" [(ngModel)]="{{editPersonne?.service}}" name="serviceId">
<option value="">Service</option>
<option [value]="service.id" *ngFor="let service of services" >{{service.designation}}</option>
</select>
</div>
or
<div class="form-group">
<label for="service">Service</label>
<select id="service" class="form-control" ngModel="{{editPersonne?.service}}" name="serviceId">
<option value="">Service</option>
<option value="{{service.id}}" *ngFor="let service of services" >{{service.designation}}</option>
</select>
</div>
I want Etat to be like this (inline):
here is the code of the select jsp
<td>
<div class="form-group">
<label for="exampleInputEmail1"><%=df.getEtatdemande() %></label>
<select class="form-control" aria-describedby="emailHelp" id="monselect" name="etatdemande">
<option value="null">NULL</option>
<option value="ACCEPTER">ACCEPTER</option>
<option value="REFUS">REFUS</option>
</select>
</div>
</td>
Looks like you are using bootstrap 4. Try to use form-inline instead of form-group
<div class="form-inline">
<label class="my-1 mr-2" for="exampleInputEmail1"><%=df.getEtatdemande() %></label>
<select class="custom-select" aria-describedby="emailHelp" id="monselect" name="etatdemande">
<option value="null">NULL</option>
<option value="ACCEPTER">ACCEPTER</option>
<option value="REFUS">REFUS</option>
</select>
</div>
How can you select a value from a drop down list when there is no option values to choose from?
This is my code to set attribute to three 3 web forms drop down lists. The first one suceedss.
WebBrowser1.Document.GetElementById("provincia")-
.SetAttribute("selectedIndex", 21)
WebBrowser1.Document.GetElementById("canton")-
.SetAttribute("selectedIndex", 1)
WebBrowser1.Document.GetElementById("parroquia")-
.SetAttribute("selectedIndex", 1)
This is the HTML code for the 3 drop down lists:
</div>
<div class="form-group">
<label class="col-md-3 control-label"
for="provincia">Provincia *</label>
<div class="col-md-8">
<select class="form-control" data-val="true"
data-val-required="El campo Provincia * es obligatorio." id="provincia"
name="provincia"><option value="">Seleccionar una provincia</option>
<option value="01">AZUAY</option>
<option value="02">BOLIVAR</option>
<option value="03">CAÑAR</option>
<option value="04">CARCHI</option>
<option value="06">CHIMBORAZO</option>
<option value="05">COTOPAXI</option>
<option value="07">EL ORO</option>
<option value="08">ESMERALDAS</option>
<option value="20">GALAPAGOS</option>
<option value="09">GUAYAS</option>
<option value="10">IMBABURA</option>
<option value="11">LOJA</option>
<option value="12">LOS RIOS</option>
<option value="13">MANABI</option>
<option value="14">MORONA SANTIAGO</option>
<option value="15">NAPO</option>
<option value="22">ORELLANA</option>
<option value="16">PASTAZA</option>
<option value="17">PICHINCHA</option>
<option value="24">SANTA ELENA</option>
<option value="23">SANTO DOMINGO DE LOS TSACHILAS</option>
<option value="21">SUCUMBIOS</option>
<option value="18">TUNGURAHUA</option>
<option value="19">ZAMORA CHINCHIPE</option>
<option value="90">ZONAS NO DELIMITADAS</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label"
for="canton">Cantón *</label>
<div class="col-md-8">
<select class="form-control" id="canton"
name="canton"></select>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label"
for="parroquia">Parroquia *</label>
<div class="col-md-8">
<select class="form-control" id="parroquia"
name="parroquia"></select>
</div>
</div>
I have succeeded at assigning value to "provincia", however I am not anywhere near that degree of success with "canton" and "parroquia". The error message I get from the website simply says that "canton" and "parroquia" are mandatory. My guess is that there is no line in both "canton" and "parroquia".
I am using bootstrap, I wanted to know is there something like a feature in bootstrap to do this?
<div class="form-group">
<label class="col-sm-6 control-label" for="textinput">Flooring material </label>
<div class="col-sm-6">
<select class="form-control" name="flooring_meterial">
<option value="0">-Select-</option>
<option value="1" >Earth,sand</option>
<option value="2">Dung</option>
<option value="3">Wood/planks</option>
<option value="4">Parquet or polished wood</option>
<option value="5">other</option>
</select>
<input type="text" placeholder="Other" class="form-control" name="f_m_other">
</div>
</div>
I want to activate this bellow input field, if the above select field value is "other"
Since I could not able to find a short cut for this using bootstrap, I thought to write this in native javascript.
function disable(select_val,input_id) {
var e = document.getElementById(select_val);
var strUser = e.options[e.selectedIndex].value;
if(strUser === "100"){
document.getElementById(input_id).disabled = false;
}
else{
document.getElementById(input_id).value = document.getElementById(input_id).defaultValue;
document.getElementById(input_id).disabled = true;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="form-group">
<label class="col-sm-6 control-label" for="textinput">Principle mode of water supply</label>
<div class="col-sm-6">
<select class="form-control" name="water_supply" id="water_supply" onchange="disable('water_supply', 'w_s_other')">
<option value="0">-Select-</option>
<option value="1">Shared/ public well</option>
<option value="4">Private pipe line</option>
<option value="5">Stream/river</option>
<option value="100" >Other</option>
</select>
<input type="text" placeholder="Other" class="form-control" name="w_s_other" id="w_s_other" disabled value="">
</div>
</div>
<div class="form-group">
<label class="col-sm-6 control-label" for="textinput">x2</label>
<div class="col-sm-6">
<select class="form-control" name="water_supply" id="x2" onchange="disable('x2', 'x2other')">
<option value="0">-Select-</option>
<option value="1">Shared/ public well</option>
<option value="5">Stream/river</option>
<option value="100" >Other</option>
</select>
<input type="text" placeholder="Other" class="form-control" name="w_s_other" id="x2other" disabled value="">
</div>
</div>
Try using change event at select element to set input disabled to true if value of select element is "5" with .prop()
$("select").change(function() {
$("+ input", this).prop("disabled", !(this.value === "5"))
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<div class="form-group">
<label class="col-sm-6 control-label" for="textinput">Flooring material </label>
<div class="col-sm-6">
<select class="form-control" name="flooring_meterial">
<option value="0">-Select-</option>
<option value="1" >Earth,sand</option>
<option value="2">Dung</option>
<option value="3">Wood/planks</option>
<option value="4">Parquet or polished wood</option>
<option value="5">other</option>
</select>
<input type="text" placeholder="Other" class="form-control" name="f_m_other" disabled="true">
</div>
</div>
i am trying to align html controls next to each other without giving huge space and I try to override the bootstrap .css but no luck.
here is my screen looks like:
I have created JSFiddle and also below is my html code.
JSFIDDLE
<div class="row">
<div class="col-xs-4">
<div class="form-group1">
<label class="col-xs-5 control-label" for="">Rows per page:</label>
<div class="col-xs-4">
<form action="/SystemAdmin" id="form_header_pager" method="post" name=
"form_header_pager">
<select class="form-control" data-val="true" data-val-number=
"The field PageSize must be a number." data-val-required=
"The PageSize field is required." id="PageSize" name=
"PageSizeSelect">
<option selected="selected" value="10">
10
</option>
<option value="25">
25
</option>
<option value="50">
50
</option>
<option value="ALL">
ALL
</option>
</select>
</form>
</div>
</div>
</div>
<div class="col-xs-4">
<div>
<div>
<b>Total records:</b> 0
</div>
</div>
</div>
<div class="col-xs-4">
<div class="form-group1">
<label class="col-xs-5 control-label" for="">Show Records:</label>
<div class="col-xs-7">
<form action="/SystemAdmin" id="form_header_show_records" method="post"
name="form_header_show_records">
<select class="form-control" id="ShowRecords" name="showrecords">
<option value="all">
Show All Records
</option>
<option value="invalid">
Show Invalid Records
</option>
<option value="valid">
Show Valid Records
</option>
</select>
</form>
</div>
</div>
</div>
</div>
The big spaces within your layout are caused from using the grid column widths. Bootstrap provides inline form element styling and it's recommended to use that instead of the grid columns.
The additional CSS adjustment I had to make was your totals area. Since it didn't have an input or select element, the vertical alignment was slightly off. If you had a row of inputs (as show in Bootstrap's documentation), you wouldn't need any additional CSS here.
You can view this corrected code snippet below. Please note that you must run it in "Full Page" mode to view it correctly. By default the form-inline tool only works in viewports greater than 768px.
.record-results {
display: inline-block;
margin-bottom: 3px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div class="form-inline">
<div class="form-group">
<form action="/SystemAdmin" id="form_header_pager" method="post" name="form_header_pager">
<label for="PageSize">Rows per page:</label>
<select class="form-control" data-val="true" data-val-number="The field PageSize must be a number." data-val-required="The PageSize field is required." id="PageSize" name="PageSizeSelect">
<option selected="selected" value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="ALL">ALL</option>
</select>
</form>
</div>
<div class="form-group ">
<span class="record-results"><strong>Total records:</strong> 0</span>
</div>
<div class="form-group">
<form action="/SystemAdmin" id="form_header_show_records" method="post" name="form_header_show_records">
<label for="showrecords">Show Records:</label>
<select class="form-control" id="ShowRecords" name="showrecords">
<option value="all">Show All Records</option>
<option value="invalid">Show Invalid Records</option>
<option value="valid">Show Valid Records</option>
</select>
</form>
</div>
</div>
JSBIN
your layout is confused me. So I did another to achieve.
The key code:
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">Rows per page:</label>
<select name="" id="" class="form-control">
<option value="1">test</option>
<option value="1">test</option>
<option value="1">test</option>
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail2">Total records:</label>
<span class="text-danger">99</span>
</div>
<div class="form-group">
<label for="exampleInputName2">Show Records:</label>
<select name="" id="" class="form-control">
<option value="1">test</option>
<option value="1">test</option>
<option value="1">test</option>
</select>
</div>
</form>