- Screen name: davidt75
davidt75's Profile
4 Posts
8 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- I've been trying to use a remote JSON datasource but just isn't working so I'm giving an XML solution a try.
The code I have is along the lines:- From: <input id="frmFlightFrom" name="frmFlightFrom" type="text" class="Airports" value="" />
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery.ajax({
url: "http://www.proudlycarbonneutral.com/CarbonFootprintCalculator/FlightList.aspx",
dataType: "xml",
success: function( xmlResponse ) {
var data = jQuery( "airport", xmlResponse ).map(function() {
return {
value: jQuery( "name", this ).text()
};
}).get();
jQuery( ".Airports" ).autocomplete({
source: data,
minLength: 0;
}
};
});
});
</script>
the XML is along the lines:- <airports>
- <totalResultsCount>3</totalResultsCount>
- <airport><name>GIG - Galeao Antonio Carlos Jobim (Brazil)</name></airport>
- <airport><name>LAX - Los Angeles International (United States)</name></airport>
- <airport><name>LOS - Lagos Murtala Muhammed (Nigeria)</name></airport>
- </airports>
Thanks
David- I'm trying to implement Autocomplete using a remote JSON datasource as the load time is excessive when I embed the list.
The datasource I have is at http://www.proudlycarbonneutral.com/CarbonFootprintCalculator/FlightList.aspx
The page where this is used is at http://www.proudlycarbonneutral.com/CarbonFootprintCalculator.aspx in the Flights section (submenu on right). It just isn't loading here and I'm not too sure why. I'd like the entire data to be searched when typing as it could be by airport name, city, or country which all appear in the AirportName field.
The code I'm using is:- jQuery( ".Airports" ).autocomplete({
source: function( request, response ) {
jQuery.ajax({
url: "http://www.proudlycarbonneutral.com/CarbonFootprintCalculator/FlightList.aspx",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function( data ) {
response( jQuery.map( data.airportlist, function( item ) {
return {
label: item.AirportName,
value: item.AirportName
}
}));
}
});
},
minLength: 2
});
Any help at all would be appreciated.
Thanks
David- 29-Jul-2011 09:04 AM
- Forum: Using jQuery
Hopefully someone here might know what I'm doing wrong.
I have a list of checkboxes, in multiple rows with each along the lines of:<tr>
<td style="text-align: center;">
<input id="frmEmployee" name="frmEmployee" value="'[PayrollRef,Employees]'" type="checkbox" checked="checked" />
</td>
<td>[FirstName,Employees] [LastName,Employees]</td>
<td style="text-align: center;">
<input id="frmUseTimesheets[PayrollRef,Employees]" name="frmUseTimesheets[PayrollRef,Employees]" value="True" type="checkbox" checked="checked" />
</td>
<td style="text-align: center;">
<input id="frmUseExpenses[PayrollRef,Employees]" name="frmUseExpenses[PayrollRef,Employees]" value="True" type="checkbox" checked="checked" />
</td>
</tr>What I want to do is when the #frmEmployee checkbox is checked/unchecked it will also check/uncheck the other two checkboxes in that same row only.
The script I have which isn't yet doing this is:
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("[id=^frmEmployee]").change(function(){
var selected = jQuery(this);
var scope = jQuery(this).parent("tr");
jQuery("[id=^frmUseTimesheets]",scope).attr('checked', selected.is(':checked'));
jQuery("[id=^frmUseExpenses]",scope).attr('checked', selected.is(':checked'));
});
});
</script>Is it something obvious that's wrong?
Thanks
David
- 19-Jul-2011 02:05 AM
- Forum: Using jQuery
I have a list of products where they have minimum quantities in a hidden input. Some products have multiple colours, though the same minimum quantity and I'm trying to implement a jQuery check that entries made are at least equal to the minimum.
Blank or '0' entries are fine but if it's below the minimum quantity it should set to the minimum.- HTML:
- <div class="ProductGrouping"> <!-- with colours -->
- <input id='frmQuickAdd1234c1' name='frmQuickAdd1234c1' type='text' style='width: 40px; text-align: center;' class='auto {mDec: 0}' value='' /> Black
-
- <input id='frmQuickAdd1234c2' name='frmQuickAdd1234c2' type='text' style='width: 40px; text-align: center;' class='auto {mDec: 0}' value='' /> White
- <input id="QuickAddMinOrderQty1234" name="QuickAddMinOrderQty1234" type="hidden" class="auto {mDec: 0}" value="6" />
- </div>
- <div class="ProductGrouping"> <!-- without colours -->
- <input id='frmQuickAdd4567' name='frmQuickAdd4567' type='text' style='width: 40px; text-align: center;' class='auto {mDec: 0}' value='' /> Product B
-
- <input id="QuickAddMinOrderQty4567" name="QuickAddMinOrderQty4567" type="hidden" class="auto {mDec: 0}" value="3" />
- </div>
- jQuery:
- <script type="text/javascript">
- jQuery(document).ready(function(){
- if (jQuery.browser.msie) {
- jQuery("[id=^frmQuickAdd]").bind("keyup", CheckStr);
- };
- jQuery('[id=^frmQuickAdd]').change(CheckMin);
- function CheckMin(){
- var AmountStr = jQuery(this);
- var Amount = Number(AmountStr.val().replace(/[$£,]+/g,""));
- var ProductScope = jQuery(this).parent("div.ProductGrouping")
- var MinQtyStr = jQuery("[id=^QuickAddMinOrderQty]",ProductScope);
- var MinQty = Number(MinQtyStr.val().replace(/[$£,]+/g,""));
- if (parseFloat(Amount) == 0){}
- else if (parseFloat(Amount) == ''){}
- else if(parseFloat(Amount) < parseFloat(MinQty)){
- AmountStr.val(MinQtyStr.val());
- };
- };
- function CheckStr(){
- if (isNaN(jQuery(this).val() )) {
- var ProductScope = jQuery(this).parent("div.ProductGrouping")
- jQuery(this).val(jQuery("[id=^QuickAddMinOrderQty]",ProductScope).val())
- }
- };
- });
- </script>
Thanks
David- «Prev
- Next »
- jQuery( ".Airports" ).autocomplete({
- From: <input id="frmFlightFrom" name="frmFlightFrom" type="text" class="Airports" value="" />
Moderate user : davidt75
© 2012 jQuery Foundation
Sponsored by
and others.


