Hi, im trying to let a user input an Address that is broken down into parts like address,city,state,zip and so on
but from some reason my ajax call wont bring in the second parameter i try to pass to i, here is the java function
The html is a basic text box
<
div
class
=
“four columns”
id
=
“navigation”
>
<
div
id
=
“instrux-body”
>
<
label
for
=
“txtSearch”
>Search Wells by Lease Name:</
label
>
<
input
type
=
“text”
id
=
“txtSearch”
/>
<
label
for
=
“txtTest”
>Field Name</
label
>
<
input
type
=
“text”
id
=
“txtTest”
/>
<
input
type
=
“button”
id
=
“btnSearch”
onclick
=
“searchWellByLeaseName()”
value
=
“Search”
/>
</
div
>
</
div
>
Is there something i have overlooked any help is appreciated
function searchWellByLeaseName() {
// Remove previous search results display, if any
$(’#well-search-results’).remove();
// Get the OpenLayers map object
var olMap = Map1.getOpenLayersMap();
// Get the query the user entered in the search textbox
var searchText = txtSearch.value;
var fieldText = txtTest.value;
// Do nothing if the query was blank or contained only whitespace
if (searchText === null || searchText.match(/^ *$/) !== null ){
return false;
}
// Call the SearchText server action with the search query and current map size
var params = { searchMode: ‘lease_name’, searchParam: searchText, fieldParam:fieldText, mapWidth: Map1.div.clientWidth, mapHeight: Map1.div.clientHeight };
Map1.ajaxCallAction(“Home.mvc”, ‘SearchWells’, params , function (result) {
// The callback contains a JSON string representing either the extent to zoom into, or a collection of features matching the query.
var returnResult = result.get_responseData();
if (returnResult != “”) {
var searchResultFeatures = JSON.parse(returnResult);
// If there was exactly one result, the return contains an extent that we should zoom into.
if (searchResultFeatures.length === 1) {
var featureExtent = searchResultFeatures[0].wkt;
olMap.zoomToExtent(OpenLayers.Geometry.fromWKT(featureExtent).getBounds(), true);
}
// If there is more than one result, display a list allowing the user to select which one they want to zoom to.
else if (searchResultFeatures.length > 1) {
var resultsMarkup = ‘<
div
id
=
“well-search-results”
><
ul
>’;
jQuery.each(searchResultFeatures, function (index, object) {
var id = object.id;
var kid;
var leaseName;
jQuery.each(object.values, function (index, object) {
if (object.Key == ‘KID’) kid = object.Value;
if (object.Key == “LEASE_NAME”) leaseName = object.Value;
});
resultsMarkup += ‘<
li
><
a
href
=
"#"
data-featureid
=
"’ + id + ‘"
title
=
“KID: ’ + kid + '”
>’ + leaseName + ‘</
a
></
li
>’;
});
resultsMarkup += ‘</
ul
>’;
$(’#instrux-body’).append(resultsMarkup);
$(’#well-search-results’).css({
top: ($(’#txtSearch’).position().top + $(’#txtSearch’).outerHeight(true)) + ‘px’,
left: $(’#txtSearch’).position().left + ‘px’,
“min-width”: $(’#txtSearch’).outerWidth(true) + ‘px’,
});
$(’#well-search-results ul’).sortList();
}
}
// If there are no results, display a message to that effect
else {
var resultsMarkup = ‘<
div
id
=
“well-search-results”
><
ul
><
li
class
=
“no-result”
>No results found.</
li
></
ul
></
div
>’;
$(’#instrux-body’).append(resultsMarkup);
$(’#well-search-results’).css({
top: ($(’#txtSearch’).position().top + $(’#txtSearch’).outerHeight(true)) + ‘px’,
left: $(’#txtSearch’).position().left + ‘px’,
“min-width”: $(’#txtSearch’).outerWidth(true) + ‘px’,
});
}
});
// Redraw the WellOverlay layer
Map1.redrawLayer(“WellOverlay”);
}