Select drop down lose $_POST value onchange form submit with IE - select

I have the following problem with form submit on select onchange event with IE. Mozilla is fine but on IE when I var_vump($_POST['makes']) I can se it is empty.. My form is this:
<form name="makes_filter" id="makes_filter" action="" enctype="multipart/form-data" method="POST" accept-charset="utf-8">
Filter by:
<select name="makes" id="makes" style="width: 120px; text-align: left; margin-right: 5px; float: left;" onchange="document.forms.makes_filter.submit();">
<option style="text-align: center;" value=""> -- Make -- </option>
<option id="APPLE" value="APPLE">APPLE</option>
<option id="HTC" value="HTC">HTC</option>
<option id="LG" value="LG">LG</option>
<option id="NOKIA " value="NOKIA ">NOKIA </option>
</select>
</form>
Can you please help me to find out why this form submits empty value on selected option?
Thank you in advance !

Problem solved by removing another select with same name/id

Related

Load dropdown item but disable for selection

So I want to be able to load the 'Choose' dropdown option, but disable it as soon as a change is made on the drop-down.
I've attempted adding a disabled attribute tag on the selection, but it loads on 'Alabama' and I don't want that.
How would I be able to tackle this?
<div class="row mt-3">
<div class="col-md">
<label for="resident">I am a resident of:</label>
</div>
</div>
Adding hidden and selected to the first option should do the trick.
<div class="row mt-3">
<div class="col-md">
<label for="resident">I am a resident of:</label>
<select class="custom-select" id="resident" required>
<option hidden selected value="">Choose...</option>
<option>Alabama</option>
<option>Alaska</option>
<option>Colorado</option>
<option>New York</option>
<option>South Dakota</option>
</select>
<div class="invalid-feedback">
Select state of residence.
</div>
</div>
</div>
If you want to still see the "Choose..." after the user has made a selection, replace hidden with disabled.
Why don't you disable the first option? (no javascript is needed and the result is like what you want to achieve I think):
<div class="row mt-3">
<div class="col-md">
<label for="resident">I am a resident of:</label>
<select class="custom-select" id="resident" required>
<option value="" disabled>Choose...</option>
<?php foreach (Vars::states() as $abbr => $state): ?>
<option value="<?= $abbr; ?>"><?= $state; ?></option>
<?php endforeach; ?>
</select>
<div class="invalid-feedback">
Select state of residence.
</div>
</div>
</div>
And a demo code snippet of what it looks like:
<select required>
<option value="" disabled selected>Select your option</option>
<option value="1">Alabama</option>
<option value="2">Alaska</option>
<option value="3">...</option>
</select>

How to align radio buttons on a Iphone safari

I'm trying to horizontally align radio buttons below their label. The code works fine on chrome on my desktop but not on a Iphone either on safari or chrome. Here's the JS Fiddle
<div>
<div class='m' >
<h3 class='m1'>RES</h3>
<h3 class='m1'>SAIL</h3>
<h3 class='m1'>Crew</h3>
<h3 class='m1'>XCL</h3>
</div>
<div class='m'>
<input class='n1' type="radio" name="rsx" id="r" value="res">
<input class='n1' type="radio" name="rsx" id="r" value="sail">
<select id='n2' name="crewopen">
<option value=""> </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>
</select>
<input class='n1' type="radio" name="rsx" id="r" value="xcl">
</div>
</div>
and the CSS
.m{
clear:both;
margin:0 auto;
width:85%;
text-align:center;
}
.m1{
float:left;
width:25%;
margin:0;
}
.n1{
width:25%;
float:left;
text-align:right;
margin:0;
-webkit-appearance: radio;
}
#n2{
float:left;
width:15%;
margin-left:5%;
margin-right:5%;
}
Horizontally and vertically align radio input with their label. This code working is fine on iPhone on both Safari and Chrome.
<input class="radio-button" type="radio" name="sn" value="yes">
.radio-button{
width:10px;
height:10px;
-webkit-appearance: radio;
}
Wow, not a lot of interest in this one! Any way the answer (or at least one that works)
.n1{
width:5%;
margin-left:10%;
margin-right:10%
}
also, if you're using bootstrap you need to add:
input[type=radio]{
margin-left:10%
margin-right:10%
}
and you can remove the margin attributes in .n1

Codeigniter - Error While Passing Variables From Container to View

Hi I want to Pass input elements values while clicking button using post method and pass values to next view using CI. When submitting the button with values in input elements and redirecting it works well. But When I'm refreshing after redirecting the page the values of input elements are lost and shows blank page/the page i display when the value becomes null.
1st View
<form action="<?php echo base_url() ?>Mapcontrol/display_garage_by_location" method="post">
<div class="section_1">
<select id="cmbcity" name="cmbcity" class="frm-field required">
<option value="null">Select Your City</option>
<option value="1">fghfghfghf</option>
<option value="2">fghfghfgh</option>
<option value="3">fghfgh</option>
<option value="4">ffffffff</option>
<option value="5">hhhh</option>
<option value="6">dddd</option>
<option value="7">treee</option>
<option value="8">kiu</option>
</select>
</div>
</div>
<div class="col-md-3 dropdown-button">
<div class="input-group">
<span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span>
<input type="text" id="txtPlaces" placeholder="Enter a location" />
<input type="hidden" id="city2" name="city2" />
<input type="hidden" id="cityLat" name="cityLat" />
<input type="hidden" id="cityLng" name="cityLng" />
</div>
</div>
<div class="col-md-3 dropdown-button">
<div class="section_1">
<select id="cmbvehicletype" name="cmbvehicletype" class="frm-field required">
<option value="null">Type</option>
<option value="cr">dd</option>
<option value="mb">ghjghjd</option>
<option value="tk">ghjghj</option>
<option value="ar">hgjghj</option>
<option value="bi">gggh</option>
<option value="ov">gg</option>
</select>
</div>
</div>
<div class="col-md-3 dropdown-button">
<div class="section_1">
<select id="cmbservice" name="cmbservice" class="frm-field required">
<option value="null">Select</option>
<option value="vr">vr</option>
<option value="oc">oc</option>
<option value="br">br</option>
<option value="vs">vc</option>
<option value="sp">cc</option>
<option value="os">cd</option>
</select>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="col-md-2 submit_button">
<input type="submit" id="searchindex" value="SEARCH"/>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
Controller
public function display_garage_by_location()
{
// Loading Library
$this->load->library('googlemaps');
//Initialize our map. Here you can also pass in additional parameters for customising the map
$this->googlemaps->initialize();
// Create the map. This will return the Javascript to be included in our pages <head></head> section and the HTML code to be
// placed where we want the map to appear.
$data['map'] = $this->googlemaps->create_map();
// Load our view, passing the map data that has just been created
//$this->load->view('my_view', $data);
$data['locationvalue']=$this->input->post('city2');
$data['latvalue']=$this->input->post('cityLat');
$data['longvalue']=$this->input->post('cityLng');
$data['vehicleid']=$this->input->post('cmbvehicletype');
$data['serviceid']=$this->input->post('cmbservice');
$this->garage_location_markers($data);
}
public function garage_location_markers($data)
{
$this->load->view('templates/_header');
$this->load->view('content/locations-in-marker-view',$data);
$this->load->view('templates/footer');
}
2nd View
// In Second View I want to display if location value is null then dispaly no data found else display search results ..
The Problem is When location is not null it displays the details but when i refresh the page again control go back to the controller and results no data found.. How to Solve this?
Try Like this
In View
View user
In Controller
public function FunctionName($id) # determine function that receiving incoming parameter
{
if (empty($id)) {
echo "Token Missed Matched";
}
else{
# get data from model
$result = $this->model_name->model_function($id);
if(empty($result))
{
echo "No data found";
}
else{
$this->load->view('view_name');
}
}
}

firefox doesn't display text value in form when selected="selected"

Firefox doesn't show form correctly (Chrome and IE show same form without any problem).
In Firefox in first line in form text value doesn't appear.
In Firefox Firebug shows:
<td>
<select id="refSearchType" size="10" name="refSearchType">
<option selected="true" label="Option1" value="Option1"></option>
<option value="Option2">Option2</option>
<option value="Option3">Option3</option>
</select>
In IE View Source shows:
<td>
<select id="refSearchType" name="refSearchType" size="10">
<option value="Option1" label="Option1" selected="selected" />
<option value="Option2">Option2</option>
<option value="Option3">Option3</option>
</select>
</td>
My jsp code:
<td>
<form:select path="refSearchType" size = "10">
<option value="${first}" label="${first}" selected="selected"/>
<form:options items="${searchList}" />
</form:select>
</td>
I tried to switch value of selected= to "true" or "yes" , doesn't work
CTRL+F5 doesn't work too
Please advice
Thank you in advance
I fixed the problem by adding ${first} in line of option value
<td>
<form:select path="refSearchType" size = "10">
<option value="${first}" label="${first}" selected="selected">${first}</selected>
<form:options items="${searchList}" />
</form:select>
</td>
This is a bug in Firefox. They don't seem to care, since this has been around since pre-HTML 2.0
https://bugzilla.mozilla.org/show_bug.cgi?id=option-label

Why my form is skipping every other item

I'm doing a project for a class, basically trying to do a survey to match people with a dorm based on their desired lifestyle. I copied the syntax for the form and some of them pop up correctly-the question appears with a drop down menu, but then the questions "how often do you plan on going to red lion" and "how do you plan on eating most of your meals" dont show up, and the options that should be in the drop down menu appear as text on the page, not as a drop down menu. any ideas? Heres the code:
<!DOCTYPE html>
<html>
<head>
<title> Find the right dorm for you </title>
<h1>Find out what dorm fits your lifestyle!</h1>
</head>
<body>
<p> Please fill out a few quesitons so we can help you figure out which dorm is best for you. </p>
<form method="get" action="slutsky1-results.php">
I enjoy (check all that apply):<br>
<input type="checkbox" name="act1" value="8">Working Out<br>
<input type="checkbox" name="act2" value="3">Bowling<br>
<input type="checkbox" name="act3" value="3">Live Music<br>
<input type="checkbox" name="act4" value="5">Shopping<br>
<input type="checkbox" name="act5" value="7">Food<br>
<input type="checkbox" name="act6" value="9">Bars <br>
<input type="checkbox" name="act7" value="9">Frat Parties <br>
<input type="checkbox" name="act8" value="8">Sports <br>
<input type="checkbox" name="act9" value="3">Library <br>
Is being close to the quad important to you?:
<select name= "Quad">
<option value="1">Not important</option>
<option value="3">Kind of important</option>
<option value="6">Very Important</option>
<option value="3">Only thing that matters</option> <br>
How often do you plan on going to Red Lion?:
<select name= "Lion">
<option value="1">Never</option>
<option value="5">Sometimes</option>
<option value="10">Over 3 times a week</option> <br>
Would you rather go to the ARC or CRCE?:
<select name= "Gym">
<option value="10">Arc</option>
<option value="1">CRCE</option>
<br>
How do you plan on eating most of your meals?:
<select name= "Gym">
<option value="5">Ordering delivery</option>
<option value="8">Walking To Green St.</option>
<option value="5">Making my own food</option>
<br>
Private or Public dorm?:
<select name= "Gym">
<option value="10">Private</option>
<option value="5">Public</option>
<br>
<input type="submit" value="get my results!">
</form>
</body>
</html>
You need to close your select tags (using </select>) after the option lists:
<select name= "Gym">
<option value="10">Arc</option>
<option value="1">CRCE</option>
</select>
Do that to every list.
You aren't closing your select tags. So the browser is trying to guess what you are trying to accomplish. Remember that all tags should be closed.
<select name= "Quad">
<option value="1">Not important</option>
<option value="3">Kind of important</option>
<option value="6">Very Important</option>
<option value="3">Only thing that matters</option>
</select>
For help finding these sorts of issues, run your page against an html validator.