JQXdropdown issue in php - php

I am using jqxdropdownlist.js for dropdown in PHP. While onchanging I need to redirect respective pages.
The probem is for example in my dropdown i have the following values.
$(document).ready(function () {
var source = [
"Affogato",
"Americano",
"Bicerin",
"Breve",
"Café Bombón",
"Café au lait",
"Caffé Corretto",
"Café Crema",
"Caffé Latte",
];
// Create a jqxDropDownList
$("#jqxdropdownlist").jqxDropDownList({ source: source, selectedIndex: 0, width: '200px', height: '25px' });
In that I want to choose "Café au lait" it should be in 2 in C series. While clicking C letter the drop down comes to 1st series of C that is Café Bombón after it will redirect to Café Bombón page. But I need to redirect to next series.
I am using the below code for Onchage function.
$("#jqxWidget").change(function(){
var val1=$("#jqxWidget").jqxDropDownList('getItem', args.index);
window.location.href=val1.value;
});
Thanks in advance.

Try using this way and see if this works for you:
// i think this will be your hidden input's id change event so
$("#jqxWidget").change(function(){
var val1=$(this).val();
window.location.href=val1;
});

Related

Loading data from database in select option html - Laravel

Hello I have issue with my jquery code, because when I want to press any key to get query from database that is not working (it is not showing any alert). I think my ajax isn't working very well because I tried to copy other code and didn't work. I want to get data from database with my skills to choose in options
jQuery code
$(document).ready(function () {
$("#skills").click(function () {
alert("test")
});
});
<select class="select2bs4" multiple="multiple" name="ums[]" data-placeholder="Skills"
style="width: 100%;" id="skills">
</select>
And I want to do when I press any key then should show any result in multiple select but at beginning didn't show any alert yet.
I tried to do like "Select2 and Laravel: Ajax Autocomplete" from Laraget website and that wasn't working too
EDIT____
If it's only input with type 'text' it's working fine to show alert
Thank you in advance
Try this
$(document).ready(function () {
$("#skills").change(function () {
alert("test")
});
});
Select will not work with click but with change , but if you want change when you write in select like search bar , replace this :
$("#skills").click(function () {
alert("test")
});
to this if you want to get the change option :
$("#skills").on('change',function () {
alert("test")
});
or this if you want to handle user input :
$("#skills").on('keyup',function () {
alert("test")
});

laravel working with city and area select

I was wondering if there is an easy way to work with multiple select boxes in Laravel. I am trying to make a city box, if the city is selected, if want to load the next controller that shows the areas in the city. Would this even be possible for a form?
Thank you
Thank you, guys.
It was quite easy to make.
Never expected it to be this easy.
I did it by setting a route to a new controller and working with javascript.
To the people that would like to make this in the near future.
Below you can find an idea of code that I have used for Laravel;
Javascript
$(document).ready(function () {
$('#city').change(function () {
var city = $("#city option:selected").val();
$.ajax({
url: "https://anma-maching-dev.aska-ltd.jp/destinations",
data: {
"city" : city
},
success: function(result){
jQuery('.area').html('');
$( ".area" ).fadeIn("fast", function() {
$(".area").append(result);
});
}
});
});
});
I attached the output of the controller to a div class called area!
route
Route::get('/destinations', 'destinationsController#get_area');
strong text
public static function get_area()
{
// your query to select the next information for your textBox
}

How to calculate the sum of ID^ with JQuery

I have two different IDs. One auto increment (using jquery) from an ID called id="H+currentRow+"(+currentRow+ is the current row). And another that does an ajax request to PHP that appends the form with an id="Z#"(# will be depending on the ID in the database).
Ive done this:
$(document).ready(function(){
$("input").change(function(){
var sum=0;
$("[id^=H]").each(function(){
sum=sum+(+parseInt(this.value));
});
var sum2=0;
$("[id^=Z]").each(function(){
sum2=sum2+(+parseInt(this.value));
});
var total = sum + sum2;
if(isNaN(total)) {
var total = 0;
}
$("#total").text(total);
});
});
But thats not working. It works for the first fields but it work for anything else thats being appended. Anyone know whats going on and why its not working?
when you bind an event direct to an element, new elements appended to page will not trigger the event. you have to bind a parent element where inputs are appended to.
Try this bind:
$('body').on('change', 'input', function () {
// your code remain the same here...
});
you can be more specifc than body, binding the event to parent elements of input.

jQuery UI & PHP - Sending 'To' Column to PHP

I am using jQuery UIs Sortable to allow a user to move items from 4 columns as well as change the order of items within each column. I have the latter working without problem; updating the new order to the database.
But I'm not sure how to handle storing moving from Column A to Column B. Each unordered list has a unique ID so I'd like to send that information along; I just don't have a firm understanding of how to do this.
$("#list1, #list2, #list3, #list4").sortable({
connectWith: ".sort",
placeholder: "shadow",
dropOnEmpty: true,
opacity: 0.8,
cursor: 'move',
update: function() {
var order = $(this).sortable("serialize") + '&update=update';
$.post("/update.php", order, function(theResponse) {
$("#alert").html(theResponse);
$("#alert").slideDown('slow');
slideout();
});
}
});
I've found an answer to my own question. The answer is to pass the data to the PHP file in a slightly different manner that allows for a more robust amount of variables (rather than just serializing one set of information).
var item = ui.item;
var new_ul = item.parent();
var order = [];
container.children('li').each(function(i){
reorder[i] = $(this).attr('id');
});
$.ajax({
method:'post',
url: 'update.php',
data:{
'new_ul':container.attr('id'),
'item':item.attr('id'),
'order':order
}
});
Full credit for this solution goes to user 'Zehee' at CodeIgniter (Who I believe got the solution from 37signals) http://codeigniter.com/forums/viewthread/175134/#831756

jquery+php send values

i have forms createds that require a value , as this this forms edits different users.
so how would i send that value from jquery? i know how to do it with combobox , but i want to do it from links :
like - name [details] when someone clicks on details the forms will pop up, so i wana mimic index.php?id=2 but with jquery, anyideas?
Do you want to display some content via JQuery with a link? Modify the selector to point to the correct DOM object, eg. an anchor tag with class "details"
$('a .details').click(function ()
{
$.get(
'index.php?id=2',
function(html)
{
$('#results').html(html);
});
});
if you want to load the content the link is pointing to, use (untested)
$('a .details').click(function ()
{
var anchor = this;
$.get(
$(anchor).attr('href'),
function(html)
{
$('#results').html(html);
});
});
if the id is stored in the li element, you can get the "id" attribute by using:
$('li').attr('id');
$('a .details').click(function ()
{ $.get( 'index.php?id=2', <--------------I need to pass that id=2 from a link thats created dynamicaly.
function(html)
{ $('#results').html(html); });});
for example, using
a
<ul id="cat" >
</ul>
i can acces , "cat" through jquery, loop through the cat elements and each li id=
will be clickable with some css
I cant figure out how to do it with normal text links!
thanks anyway dspinozzi

Categories