jQWidgets Forums
jQuery UI Widgets › Forums › Lists › ListBox › Bind listbox to mysql and bind another listbox with where query
Tagged: listbox mysql php
This topic contains 2 replies, has 1 voice, and was last updated by eck8tor 11 years, 9 months ago.
-
Author
-
September 23, 2013 at 2:39 pm Bind listbox to mysql and bind another listbox with where query #29385
Hi !
I would like to thank you so much for this site. It’s amazing and so great.
I test “Bind listbox to mysql” and it work succesfully.
But now, I would like to know how to create another listbox just beside the first one after I select a value and it generate another listbox where I put the value in WHERE query.
By example:
1st listbox contain music genre (ie: alternative, rock, metal, rap, etc.)
2nd listbox will display band from the genre I select
What I would like to do with those listbox it’s a Itunes genre
Thanks in advance
Eck8tor
September 26, 2013 at 6:51 pm Bind listbox to mysql and bind another listbox with where query #29632I’m almost there…. but I need an explanation.
This is my code of my index.php
$(document).ready(function ()
{
// prepare the data
var source =
{
datatype: “json”,
datafields:
[
//{ name: ‘Divsion’, type: ‘string’},
{ name: ‘genre’, type: ‘string’}
],
url: ‘genre.php’
};var dataAdapter = new $.jqx.dataAdapter(source);
$(“#genrelistbox”).jqxListBox(
{
source: dataAdapter,
theme: ‘classic’,
width: 350,
height: 250,
displayMember: ‘Divsion’,
valueMember: ‘genre’
});var groupe =
{
datatype: “json”,
//type: “POST”,
datafields:
[
{ name: ‘artiste’, type: ‘string’}
],
url: ‘groupe.php’
};console.log(groupe);
var groupeAdapter = new $.jqx.dataAdapter(groupe);$(“#groupelistbox”).jqxListBox(
{
source: groupeAdapter,
theme: ‘classic’,
width: 350,
height: 250,
valueMember: ‘artiste’
});$(‘#genrelistbox’).bind(‘change’, function (event) {
newid=$(this).val();var newdata = “id=” + newid;
var changegroupe =
{
datatype: “json”,
type: “GET”,
datafields:
[
{ name: ‘artiste’, type: ‘string’}
],
url:’groupe.php?id=’+newid
…
or
url:’groupe.php’,
data: newid
};console.log(changegroupe);
console.log(newdata);
var changegroupeAdapter = new $.jqx.dataAdapter(changegroupe);$(“#groupelistbox”).jqxListBox(
{
source: changegroupeAdapter,
theme: ‘classic’,
width: 350,
height: 250,
valueMember: ‘artiste’
});
console.log(“var groupe : ” + newid);
});});
Where I call $(‘#genrelistbox’).bind(‘change’, function (event) {, I try to pass to the url a variable (ie:groupe.php?id=Alternative)
But the groupe.php didn’t receive the variable.
Where is my error ?
September 27, 2013 at 3:34 pm Bind listbox to mysql and bind another listbox with where query #29731Case close !
I found my problem, by passing an argument, for the debug purpose, I echo my argument and it was returning. So the string was not the same.
-
AuthorPosts
You must be logged in to reply to this topic.