jQWidgets Forums
jQuery UI Widgets › Forums › Lists › ComboBox › Strange problem with dynamic loading in Combo
Tagged: combo box
This topic contains 2 replies, has 2 voices, and was last updated by vivawidget 10 years, 7 months ago.
-
Author
-
Hi,
I have a combo with data connections as follows:
var source = { datatype: "json", datafields: [ { name: 'lang' }, ], data: {fileName: 'EP_001'}, url: 'data.php' }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxcombobox").jqxComboBox( { source: dataAdapter, theme: 'classic', width: 200, height: 25, selectedIndex: 0, displayMember: 'lang', valueMember: 'lang' });
and this is linked to a data.php (below) which I have copied from your website and only changed the query
<?php include('connect.php'); $connect = mysql_connect($hostname, $username, $password) or die('Could not connect: ' . mysql_error()); mysql_select_db($database, $connect); $bool = mysql_select_db($database, $connect); if ($bool === False){ print "can't find $database"; } $fileName = $_POST["fileName"]; // get data and store in a json array $query = "SELECT * FROM lang"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $lang[] = array( 'lang_id' => $row['lang_id'], 'lang' => $row['lang'] ); } echo json_encode($lang); ?>
When I comment out the line ‘$fileName = $_POST[“fileName”];’ in data.php, the combo fills up fine. The moment I uncomment it, the combo does not fill up although when I debug the data.php, I get the correct value passed to fileName. If I hard code it in data.php instead of $_POST, it also works fine. I really have no clue as to what is happening. Although $fineName is not used in data.php further, I need it to change the query dynamically depending on its contents.
I appreciate any help.
Regards,
Rajiv
Hi Rajiv,
If you want to use $_POST, then you’ll have to set type: “POST” in the dataAdapter’s source object, because by default it is “GET”.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Thanks a lot, Peter. Nice to see the solution first thing in the morning!
-
AuthorPosts
You must be logged in to reply to this topic.