I have few select dropdown working nicely with selectize.js. On form post, it appears it only send the last option selected. So for example, if the user select's: A, B, C in the form post var_dump($_POST); only C appears. Same is the case with other select.
I went through the documentation and searched online but not able to rectify, I am sure its something really trivial but till I know, I don't know :(
Would greatly appreciate any help! Thank you!
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://brianreavis.github.io/selectize.js/js/selectize.js"></script>
<?php
if(isset($_POST["save"])){
echo '<pre>';
print_r($_POST);
echo '</pre>';
}
?>
<form action="" method="post">
<label>Select Class(s)</label>
<select multiple id="classname" name="classname[]" required class="form-control">
<option value="1">NUR</option>
<option value="2">KG</option>
<option value="3">PREP</option>
<option value="4">I</option>
<option value="5">II</option>
</select>
<label>Subjects</label>
<select multiple id="subjects" name="subjects[]" required class="form-control">
<option value="1">English</option>
<option value="2">EVS</option>
<option value="3">Maths</option>
<option value="4">Science</option>
<option value="5">Social</option>
</select>
<label>Examinations</label>
<select multiple="multiple" id="exams" name="exams[]" required="true" class="form-control">
<option value="1">Formative Assessment I</option>
<option value="2">Formative Assessment II</option>
<option value="3">Formative Assessment III</option>
<option value="4">Formative Assessment IV</option>
<option value="5">Annual</option>
</select>
<input type="submit" name="save" value="save" />
</form>
<script>
$(document).ready(function () {
$('#exams').selectize({
hideSelected: 'true'
});
$('#subjects').selectize({
hideSelected: 'true'
});
$('#classname').selectize({
hideSelected: 'true'
});
});
</script>
Related
I am using fastselect plugin in multiple selection mode.
Dropdown have this value
<select class="multipleSelect" multiple name="language[]">
<option value="1">Bangladesh</option>
<option value="2">Barbados</option>
<option value="3">Belarus</option>
<option value="4">Belgium</option>
...
</select>
Plugin is use like
$('.multipleSelect').fastselect();
When i select => 2,3,1,4 then it will like
<select class="multipleSelect" multiple name="language[]">
<option selected value="1">Bangladesh</option>
<option selected value="2">Barbados</option>
<option selected value="3">Belarus</option>
<option selected value="4">Belgium</option>
...
</select>
Whwn i post this form it will give me language[ ] array always => 1,2,3,4
i need language[ ] array in selection mode => 2,3,1,4
Thanks in advance
$('.multipleSelect').fastselect();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://rawgit.com/dbrekalo/fastselect/master/dist/fastselect.min.css">
<script src="https://rawgit.com/dbrekalo/fastsearch/master/dist/fastsearch.min.js"></script>
<script src="https://rawgit.com/dbrekalo/fastselect/master/dist/fastselect.min.js"></script>
<form name="myform" method="post">
<select class="multipleSelect" multiple name="language">
<option value="1">Apple </option>
<option value="2">Orange </option>
<option value="3">Mango </option>
</select>
<br><br><br><br><br>
<button name="submit" name="submit"> Submit </button>
</form>
I want to pass Drop Down value to php, i am new to PHP please help
<html>
<head>
<script>
function displayVals() {
var singleValues = $("#account").val();
$("p").html("<b>Single:</b> " + singleValues);
}
</script>
<select id="account" name="account">
<option value="1">Tes1</option>
<option value="2">Tes2</option>
</select>
</head>
<body>
<?php
$account = $_get['account'];
echo $account;
?>
</body>
</html>
Hi, I want to pass Drop Down value to php, i am new to PHP please help
<?php
if (isset($_POST['submit'])) {
echo $_POST['account'];
}
?>
<form action="" method="POST">
<select id="account" name="account">
<option value="1">Tes1</option>
<option value="2">Tes2</option>
</select>
<input type="submit" name="submit"/>
</form>
You need to make a form
Here is the solution for you,
<?php
if (isset($_REQUEST['save'])) {
$sql = "SELECT Business_Unit, COUNT(Joining_Month) AS 'A' FROM jl WHERE Business_Unit = '".$_REQUEST['opt']."' GROUP BY Business_Unit";
// Here is your sql query
echo $sql;exit();
}
?>
Yor HTML code:
<form method="post" action="">
<select name="opt">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
<input type="submit" name="save" />
</form>
Given simple working demo to fulfill your requirement. Hope it will help you.
how do i get the select tag value, i am using the syntax below but not working.
Controller
'role' => $this->input->post('rol'));
View
these are the options in my select tag
<select name="rol">
<option value="Employee">Employee</option>
<option value="HR">HR</option>
<option value="Student">Student</option>
</select>
$role = $this->input->post("rol");
Just try it to post like below:
<form action="your_controller_action" method="POST">
<select name="rol" id="pos_select" class="form_input">
<option value="Employee">Employee </option>
<option value="HR">HR</option>
<option value="Student">Student</option>
</select>
<input type="submit" name="submit" value="Post it">
</form>
Then in your controller:
public function youControllerAction() {
if( $this->input->post) {
echo $this->input->post("rol");
}
}
You will get the selected option value.
how did you write your selection dropdown list!did you take it as i posted below?
<select name="rol" id="pos_select" class="form_input">
<option value="Employee">Employee </option>
<option value="HR">HR</option>
<option value="Student">Student</option>
</select>
$role = $this->input->post("rol");
put this code in view. Only you have to call controller function in action. In this example I am getting option values from database
<form method="post" action="<?php echo base_url()."main/project_filter_skills"; ?>">
<select class="demo-default " id="skilltags" name="skilltags[]" data-placeholder="Choose skills">
<option value="">Choose skills</option>
<?php foreach ($all_skill_tags as $skilltags) { ?>
<option value="<?php echo $skilltags->secondCat_id;?>">
<?php echo $skilltags->secondCat_title;?>
</option>
<?php } ?>
</select>
</form>
now put this in modal or controller to get the vlaue
$skilltags= $this->input->post('skilltags');
I am having problem in my search box, actually i have created a search box for multiple selection and it is working properly,
<input type="text" name="search" size=15 maxlength=15 placeholder = "Gene Symbol"/>
<select name="table[]" size = "0" multiple>
<option selected="selected"></option>
<option value="infla_info">Inflammation</option>
<option value="diet_info">diet</option>
<option value="obesity_info">obesity</option>
<option value="stress_info">stress</option>
<option value="athero_info">atherosclerosis</option>
<option value="retino_info">Diabetic Retinopathy</option>
<option value="nephro_info">Diabetic Nephropathy</option>
<option value="neuro_info">Diabetic Neuropathy</option>
</select>
<input type="Submit" name="Submit" value="Gene Search"/>
after this i want to add one more option select all, by which it should show all the records or tables containing query gene.
please help me
try this
Jquery Code:
$('#selectall').click(function() {
$('#countries option').prop('selected', true);
});
Live Demo :
http://jsfiddle.net/3nUPF/177/
You can achieve this using jQuery :
EDIT :- You can select multiple value by pressing Ctrl button of your keyboard and you can get those value using print_r($_POST['countries']);
<select name="countries" id="countries" MULTIPLE size="8">
<option value="all">Select all</option>
<option value="UK">UK</option>
<option value="US">US</option>
<option value="Canada">Canada</option>
<option value="France">France</option>
<option value="India">India</option>
<option value="China">China</option>
</select>
jQuery :
<script>
$(document).ready(function()
{
$('#countries').change(function() {
if($(this).val() == 'all')
{
$('#countries option').prop('selected', true);
}
});
});
</script>
Working Demo
I have a multiple select. How can make, that all options will be selected always? Or how make a selecting all options ob submit. I have only class of select(not ID).
I think you can even write your replacement line like this:
$(".someClass option").attr("selected", "selected");
to avoid the .each() loop.
Here's a slight modific to Kitsched's code to ensure that you're able to select the button/select control if you only have the class and not the id.
<html id="html">
<body id="body">
<script src="file:\\\D:\Sidharth\javascript\jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
function SelectAll() {
$(".someClass").children().each(function () { $(this).attr("selected", "selected"); });
}
$(".clickme").bind("click", SelectAll);
});
</script>
<input type="submit" class="clickme" />
<select multiple="yes" class="someClass">
<OPTION VALUE="1" id="one">Option 1</OPTION>
<OPTION VALUE="2" id="two">Option 2</OPTION>
<OPTION VALUE="3" id="three">Option 3</OPTION>
<OPTION VALUE="4" id="four">Option 4</OPTION>
</select>
</div>
</body>
</html>
If you've IDs for either button or select just replace the . with # in script. For e.g. if button's id is clickme instead of class just use #clickme instead of .clickme.
Hope this is what you're looking for.
I'm not 100% sure that this is what you're asking for, but here it goes:
<SELECT MULTIPLE="yes" ID="multipleSelect">
<OPTION VALUE="1" SELECTED="selected">Option 1</OPTION>
<OPTION VALUE="2" SELECTED="selected">Option 2</OPTION>
<OPTION VALUE="3" SELECTED="selected">Option 3</OPTION>
<OPTION VALUE="4" SELECTED="selected">Option 4</OPTION>
<OPTION VALUE="5" SELECTED="selected">Option 5</OPTION>
<OPTION VALUE="6" SELECTED="selected">Option 6</OPTION>
</SELECT>
<INPUT TYPE="submit" ID="submit" value="Go!"/>
For the dynamic option (with jQuery):
$("#submit").click(function() {
$("#multipleSelect option").each(function() {
$(this).attr("selected", "selected");
});
});
Untested.
Good luck.