How to show the data list labels but submit the actual value to the database?
<div class="form-group">
<label for="reg_input">Parent Name</label>
<input list="parentName" name="parentsName" id="parentsName" class="form-control">
<datalist style="color: #FFF" id="parentName">
<?php
$pa="select * from parents";
$par=mysql_query($pa);
while ($childrens=mysql_fetch_array($par)) {
?>
<option value="<?php echo $childrens['UserName'];?>" data-value="<?php echo $childrens['UserID'] ?>"></option>
<?php
}
?>
</datalist>
</div>
Related
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>
I have created a simple form type page as follows,
<form action="" method="GET" >
<div class="input-group mb-3">
<input type="text" name="search" required value="<?php if(isset($_GET['search'])){echo $_GET['search']; } ?>" class="form-control" placeholder="Search data">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</form>
I need to type a text in search box(name ="search") and after clicking submit I need to filter the sql data as follows.
<?php
$con = mysqli_connect("10.62.96.133", "root", "", "cdrextend");
if(isset($_GET['search']))
{
$filtervalues = $_GET['search'];
$query="***";
$query_run = mysqli_query($con, $query);
if(mysqli_num_rows($query_run) > 0)
{
foreach($query_run as $items)
{
?>
<tr>
<td><?= $items['***']; ?></td>
<td><?= $items['***']; ?></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td colspan="2">No Record Found</td>
</tr>
<?php
}
}
?>
Whenever I hit submit button after typing something in text box, it redirects to login page and I am not getting any results.Can someone show me where I have messed up?
Hi change your forms submit action="" to action="<?php echo htmlspecialchars($_SERVER[" PHP_SELF "]);?>"
<form action="<?php echo htmlspecialchars($_SERVER[" PHP_SELF "]);?>" method="GET" >
<div class="input-group mb-3">
<input type="text" name="search" required value="<?php if(isset($_GET['search'])){echo $_GET['search']; } ?>" class="form-control" placeholder="Search data">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</form>
i have a form to be displayed in HTML format, the form HTML code is like below:
<form action="<?php echo base_url('editAllProductsAction'); ?>" method="post">
<?php foreach($products as $key=>$val){ ?>
<div class="row">
<h5></h5>
<input type="hidden" value="<?php echo $val['id']; ?>" name="id[]" />
<div class="col-lg-3">
<label>Product Name</label>
<input name="product_name[]" value="<?php echo $val['product_name']; ?>" type="text" class="form-control" />
</div>
<div class="col-lg-3">
<label>Min Qty </label>
<select name="min_qty[]" class="form-control">
<?php for($i=1;$i<50;$i++){ ?>
<option <?php if($i==$val[ 'min_qty']) echo 'selected'; ?> value="
<?php echo $i; ?>">
<?php echo $i; ?>
</option>
<?php }?>
</select>
</div>
<div class="col-lg-3">
<label>Purchase Price </label>
<input name="purchase_price[]" value="<?php echo $val['purchase_price']; ?>" type="number" data-id="<?php echo $val['id']; ?>" class="form-control edit_purchase_price" />
</div>
<div class="col-lg-3">
<label>Nosh Price </label>
<input name="nosh_price[]" value="<?php echo $val['nosh_price']; ?>" type="number" class="form-control edit_nosh_price_<?php echo $val['id']; ?>" />
</div>
</div>
<?php } ?>
<button type="submit" class="btn btn-primary right_side">Submit</button>
</form>
as you can see I have used php to display the values in the form, when I am displaying the form, because all the row is having same white color as background like below, which is awkward:
I am trying to give 2 background colors for the form, like in first row all input background color will display one color, the second row all the input background will show different colors and it continues for each row. i did the following css:
.form-control:nth-child(2n+1) {
background-color: grey;
}
but this is not displaying the color, can anyone tell me what I did wrong here. thanks in advance
:nth-child(2n+1) part of your code will work for form-control class living on the same level as siblings. There is no other form-control class as sibling on the same level. They live inside different column. That's why 2n+1 cannot find the third form-control inside it's own level. So, basically you have to target the class col-lg-3 as the :nth-child(2n+1). Like so should work-
.col-lg-3:nth-child(2n+1) {
background-color: grey;
}
That way you are selecting every other column and then the eventual form-control class if you want to style them differently per column basis.
You can visually see it here- https://css-tricks.com/examples/nth-child-tester/
Edit:
With further clarification, here is the code that should work in this case and the above explanations stands with a little bit of selector change-
.row:nth-child(2n+1) .form-control {
background-color: #000;
}
You have to give the class row instead of form-control
.row:nth-child(2n+1){
background: grey;
}
A picture says more than long explainations, here's my probleme :
As you can see in the pic, when too many options are selected with the select2 modal, it goes out of borders and give this ugly displaying.
Here is the source code of the select2 :
<div class="form-group row">
<label class="col-sm-3 text-right control-label col-form-label">Liste des metiers</label>
<div class="col-sm-9">
<select class="select2 form-control" multiple="multiple" style="height: 36px;width: 100%;" id="metiers">
<?php foreach ($metiers as $metier) { ?>
<option value="<?php echo $metier['nom_metier'] ?>" <?php if (isset($entreprise_metiers[$metier['nom_metier']])) echo ('selected') ?>><?php echo $metier['nom_metier'] ?></option>
<?php } ?>
</select>
</div>
So, if you guys have a solution for this, I'll gratefully take it
I have one view candidate details form in my application.
In that I gave one button called scheduled interview.
So when I click on the button it redirect the page to candidate process page with the candidate_id and user_id in the url.
And in the candidate_process page I have one form with some details and under the form I display all the records from database in data table.
I want to display the records only for the particular candidate.I don't want to display all the records.
Here is my view:
<form method="post" action="" id="form">
<b>Date </b>:<input type="text" name="date" id="date"><br><br>
<input type="hidden" name="candidate_id" value="<?php echo $getCandidate['candidate_id']; ?>">
<input type="hidden" name="user_id" value="<?php echo $getCandidate['user_id']; ?>">
<div class="form-group">
<label><b>Select Interview Type:</b></label>
<select class="form-control" id="interview_type_id" name="interview_type_id" >
<option value="" disabled selected>Interview Type</option>
<?php foreach($interviewtype as $rows) { ?>
<option value="<?php echo $rows->interview_type_id?>"><?php echo ucfirst($rows->interview_type_name)?></option>
<?php } ?>
</select>
</div><br>
<div class="form-group">
<label><b>Select Status:</b></label>
<select class="form-control" id="status_type_id" name="status_type_id" >
<option value="" disabled selected>Status Type</option>
<?php foreach($statustype as $rows) { ?>
<option value="<?php echo $rows->status_type_id?>"><?php echo ucfirst($rows->status)?></option>
<?php } ?>
</select>
</div><br>
<button type="submit" name="submit" value="submit" class="btn btn-primary" value="submit">Submit</button>
<button type="submit" id="submit" name="submit" class="btn btn-primary" value="schedule" onclick="ScheduleNextRound();">Schedule Next Round</button><br></br>
</form>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h3>Reports</h3>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-body">
<table id="example1" class="table table-bordered table-hover">
<thead>
<tr>
<th>Interview Date</th>
<th>Candidate</th>
<th>interview</th>
<th>status</th>
<th>Vendor</th>
</tr>
</thead>
<?php foreach ($view_candidates as $idata){ ?>
<tbody>
<tr id="domain<?php echo $idata->candidate_seletion_id;?>">
<td><?php echo $idata->date;?></td>
<td><?php echo $idata->f_name;?></td>
<td><?php echo $idata->interview_type_name;?></td>
<td><?php echo $idata->status;?></td>
<td><?php echo $idata->first_name;?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
</div>
</section>
</div>
Controller:
function candidate_process($candidateid,$userid){
$data["msg"]="";
$this->load->model('CandidateModel');
$data['statustype']=$this->CandidateModel->getstatustypes();
$data['interviewtype']=$this->CandidateModel->getinterviewtypes();
$data['candidate']=$this->CandidateModel->getcandidates();
$data['usertype']=$this->CandidateModel->getvendors();
$data['getCandidate'] = $this->CandidateModel->get_candidate_detail($candidateid);
$data['view_candidates'] = $this->CandidateModel->getcandidateselection();//this is my table view
if($this->input->post('submit')=="submit"){
$this->CandidateModel->add_candidate_selection($this->input->post());
redirect(base_url('Candidate/view_candidate_selection'));
}
$this->load->view('Candidates/candidate_process',$data);
}
Model1:
public function add_candidate_selection($data){
$data=array(
'candidate_id'=>$this->input->post('candidate_id'),
'user_id'=>$this->input->post('user_id'),
'status_type_id'=>$this->input->post('status_type_id'),
'interview_type_id'=>$this->input->post('interview_type_id'),
'date'=>$this->input->post('date')
);
$this->db->insert('candidate_selection', $data);
//print_r($data);
}
MOdel2:
public function getcandidateselection(){
$this->db->select('*');
$this->db->from('candidate_selection');
$this->db- >join('candidates_details','candidates_details.candidate_id=candidate_selection.candidate_id');
$this->db->join('interview_types','interview_types.interview_type_id=candidate_selection.interview_type_id');
$this->db->join('status_types','status_types.status_type_id=candidate_selection.status_type_id');
$this->db->join('users','users.user_id=candidate_selection.user_id');
$query = $this->db->get();
//echo $this->db->last_query();
return $query->result();
}
Can anyone help me how to do this..
Thanks in advance.
Replace the Following code in your model function
function getcandidateselection($candidateid)
{
$this->db->join('candidate_selection as cs','cs.candidate_id = cd.candidate_id');
$this->db->join('status_types as st','st.status_type_id = cs.status_type_id');
$this->db->where('cd.candidate_id',$candidateid);
$q = $this->db->get('candidates_details as cd');
return $q->result();
}
Hope it will solve your problem