If I press the enter key after giving the text box value like 03/20/2014 the result will appear. But if I give the value using date picker that doesn't work.
<input class="search-query" id="date" onkeypress="if(event.keyCode==13){return true;}" type="text" name="date" value="" placeholder="mm/dd/yyyy">
<script>
$(function() {
$( "#date" ).datepicker();
});
</script>
if you want to get the date when the user selects it, you can do something like this:
$ ("#datepicker").datepicker (
{
onSelect: function ()
{
var date = $(this).datepicker('getDate');
}
});
Related
I've used jquery to get an "id" as a value for an input according to a dropdown value. Now the problem is, I want to use the 'id' to insert value to some other inputs. I don't know which event method to be used. For testing, I used the keyup method to check if the code works, when I manually type in a number, it works. So the problem is with the event method I choose. Please give me some suggestions.
//Get id
$(document).ready(function() {
$('#salary_eid').change(function() {
var sid = $(this).val();
var data_String = 'sid=' + sid;
$.get('search1.php', data_String, function(result) {
$.each(result, function(){
$('#can').val(this.c_id);
});
});
});
//display other information
$('#can').change(function() {
var id = $(this).val();
var data_String1 = 'id=' + id;
$.get('search.php', data_String1, function(result1) {
$.each(result1, function(){
$('#morning_rate').val(this.cMorning);
$('#night_rate').val(this.cNight);
$('#ot_rate').val(this.clientOt);
});
});
});
});
<label>Name</label>
<input type="text" name="salary_eid" />
<select id="salary_eid">
<option>opt1</option>
<option>opt2</option>
</select>
<input type="hidden" name="can" id="can" class="form-control" >
You can trigger the keyup() event from the id code, this will then work through a manual or jQuery edit,
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
//Get id
$(document).ready(function() {
$('#salary_eid').change(function() {
var sid = $(this).val();
$('#can').val(sid).keyup();
});
});
//display other information
$(document).on('keyup', '#can', function() {
console.log($(this).val())
});
</script>
<label>Name</label>
<input type="text" name="salary_eid" />
<select id="salary_eid">
<option>opt1</option>
<option>opt2</option>
</select>
<input type="text" name="can" id="can" class="form-control" />
If you are going to hide the second input then I might suggest using a function instead without an input,
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
//Get id
$(document).ready(function() {
$('#salary_eid').change(function() {
var sid = $(this).val();
display_info(sid)
});
});
//display other information
function display_info(value) {
console.log(value)
};
</script>
<label>Name</label>
<input type="text" name="salary_eid" />
<select id="salary_eid">
<option>opt1</option>
<option>opt2</option>
</select>
I am using a Codeigniter script purchased in Codecanyon. I need add the input datepicker but in Controller cannot get from UI picked date.
UI:
<input type="date" class="form-control datetimepicker" value="<?php echo date('Y-m-d'); ?>" name="deadline" id="deadline">
Controller :
$deadline = date("Y-m-d", strtotime($this->input->post('deadline')));
I have test to show before update database but it's display current time:
var_dump($deadline);
return;
The modal you're dealing with is outside the form. I made it that - using jquery - when the date field is changed, it updates the value of its hidden field which is in the form. So when the modal triggers form submission, the value of its date field is also submitted to the controller.
HTML:
<input type="hidden" name="deadline" id="deadlinehidden" value="" />
JS:
$("#deadline").on("change paste keyup", function() {
$("#pos-sale-form input[name='deadline']").val($(this).val());
});
you can use this:
<input name="deadline" type="text" value="2017-07-08" class="form-control datepicker" id="datepicker">
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
$date=$this->input->post('deadline');
<script>
$(document).ready(function(){
var spinner = $( "#spinner" ).spinner();
$('#spinner').autocomplete({
source:'name.php'
});
$( "#getvalue" ).on( "click", function() {
alert( spinner.spinner( "value" ) );
});
});
</script>
<body>
<label for="spinner">To search name type here:=</label>
<input id="spinner" name="value"/>
<p>
<button id="getvalue">Get value</button>
</p>
</body>[1]
Above is the snapshot of the output and i want to get the particular value from this dropdown on get value button clicked and above is jQuery code and html code.
Value from the spinner field can be extracted like this:
$( "#getvalue" ).on( "click", function() {
.
.
value = $("#spinner").val();
alert(value);
});
I'm trying to create a text box that will search a mysql database, provide auto completed text below the text box and then show a confirmation tick or cross to show that the name is already in the database (or not).
I've got it to work with just one text box, but I'd like to add multiple text-boxes on the same page. eg so someone can search for 10 different names, have them all auto completed and then shown with either a green tick or red cross to confirm that they are in the database.
I'm new at this so apologies if it is something obvious that I'm doing wrong!
Thanks in advance.
This is the javascript:
<script type="text/javascript">
function check_username(){
var username = $("#username").val();
if(username.length > 2){
$.post("username.php", {
username: $('#username').val(),
}, function(response){
$('#Info').fadeOut();
setTimeout("finishAjax('Info', '"+escape(response)+"')", 450);
});
return false;
}
}
function finishAjax(id, response){
$('#'+id).html(unescape(response));
$('#'+id).fadeIn(1000);
}
$(function() {
$( "#username" ).autocomplete(
{
source:'source.php' })
});
</script>
This the the html textfield:
<td><input type="text" id="username" type="text" onblur="return check_username();"/></td>
<td><div id="Info"></div></td>
<td><input type="text" id="username2" type="text" onblur="return check_username2();"/></td>
<td><div id="Info"></div></td>
try:
$( "input#username,input#username2" ).autocomplete(
instead of
$( "#username" ).autocomplete(
I create a textbox and add a Jquery UI datepicker.But when I select and click the button.the textbox doesnt get post and show an error message like(Notice: Undefined index: date_text in C:....................\file.php on line 57 ).But when I enter a date using keyboard without having a datepicker it will submit well.Please help me.How can I do this having datepicker
this is my jquery code
<script>
$(function() {
$( "#datepicker" ).datepicker();
$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
});
</script>
this is my textfield
<div id="datetobe">Date to be dispose
<label for="date_to_dispose"> <input name="datepicker" type="text" id="datepicker" class="textfield" /></label>
</div>
You have to set the callback function for the datepicker.
http://jqueryui.com/demos/datepicker/
Events tab, onSelect event. RTM.
$('#datepicker').datepicker({
format: 'whatever',
onSelect: function(dateText, inst) { ... }
});