help needed in retrieving the value of a jquery ui combobox?
i would like to retrieve using php $_post, the inputted value of a combobox. i have been searching all over Google for several days now for examples however i cannot seem to find anything. if someone could post an example of this it would be great.
thanks in advance, please let me know if i can provide more information to you assist me
here is my code
- <?php
- //this is where i want to echo the inputted and or selected combobox value
- if (isset($_POST['submit'])){
- echo $_POST['combobox'];
- }
- ?>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.1.custom.css" />
- <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
- <script type="text/javascript" src="js/jquery-ui-1.8.1.custom.min.js"></script>
- <script type="text/javascript">
- (function($) {
- $.widget("ui.combobox", {
- _create: function() {
- var self = this;
- var select = this.element.hide();
- var input = $("<input>")
- .insertAfter(select)
- .autocomplete({
- source: function(request, response) {
- var matcher = new RegExp(request.term, "i");
- response(select.children("option").map(function() {
- var text = $(this).text();
- if (this.value && (!request.term || matcher.test(text)))
- return {
- id: this.value,
- label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
- value: text
- };
- }));
- },
- delay: 0,
- change: function(event, ui) {
- if (!ui.item) {
- // remove invalid value, as it didn't match anything
- $(this).val("");
- return false;
- }
- select.val(ui.item.id);
- self._trigger("selected", event, {
- item: select.find("[value='" + ui.item.id + "']")
- });
- },
- minLength: 0
- })
- .addClass("ui-widget ui-widget-content ui-corner-left");
- //i changed this line cause it was refreshing on its own when placed inside a form tag
- $("<div type='button'> </div>")
- .attr("tabIndex", -1)
- .attr("title", "Show All Items")
- .insertAfter(input)
- .button({
- icons: {
- primary: "ui-icon-triangle-1-s"
- },
- text: false
- }).removeClass("ui-corner-all")
- .addClass("ui-corner-right ui-button-icon")
- .click(function() {
- // close if already visible
- if (input.autocomplete("widget").is(":visible")) {
- input.autocomplete("close");
- return;
- }
- // pass empty string as value to search for, displaying all results
- input.autocomplete("search", "");
- input.focus();
- });
- }
- });
- })(jQuery);
- $(function() {
- $("#combobox").combobox();
- $("#toggle").click(function() {
- $("#combobox").toggle();
- });
- });
- </script>
- </head>
<body>
<div class="ui-widget">
<form id="form1" name="form1" method="post" action="">
<label>Your preferred programming language: </label>
<select name="combobox" id="combobox" >
<option value="">Select one...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="submit" name="submit" id="button" value="Submit" />
</form>
</div>
</body>
</html>