Tony
unread,May 21, 2013, 6:28:05 AM5/21/13You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
When I fetch data from the database I display these in either a html table
control or in a html select control.
I hope to use the same function that fetch these data.
I use this GetData function. There is a small problem here because
show_Frsvoyage is using json and asynchonous call.
I pass an argument myBool. If this is true I would display data in a html
table else display in select control.
The work done is GetData where the check is done on myBool is not working
when we have calls like these two
GetDataForTable(false, "");
GetDataForTable(true, "");
When I have done this call GetDataForTable(true, "");
I would assume that myBool is true but almost always it's false.
So my question is if it's possible to use only one function to get data by
using some kind of workaround or do I have to use two functions to
get data
function GetData(myBool, Vesselname)
{
//index holder for array
var i = 0;
//false means get all records that fulfill the search condition
on server
//You get duplicate on vesselname
show_Frsvoyage(myBool, Vesselname, function (data, textStatus,
jqXHR)
{
if (IsOkMessageShort(data.dsError))
{
// Clear array
voyageArr = [];
$.each(data.dssFrsvoyage.ttsFrsvoyage, function (key,
value)
{
// Replace T with "" and "-" with "/"
value.Arrtime = value.Arrtime.replace(/-/g,
'/').replace(/T/g, ' ').substring(0, 16);
value.Deptime = value.Deptime.replace(/-/g,
'/').replace(/T/g, ' ').substring(0, 16);
//Add to array
voyageArr[i++] = { Arrtime: value.Arrtime, Deptime:
value.Deptime, Vesselid: value.Vesselid, VesselName: value.VesselName, Port:
value.port, NextPort: value.nextport, PrevPort: value.prevport }
});
if (myBool == false)
{
//Sort the array
Sort("Vesselid_Arrtime");
//Display the array
Display("table");
}
else
{
//Sort the array
Sort("VesselName");
//Display the array
Display("select");
}
}
});
}
I can solve this problem by using two different functions that fetch data
from the database but I would rather use only one function as I said before.
//Tony