Search Results

Search found 39207 results on 1569 pages for 'foreign function interfac'.

Page 12/1569 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Variable function name Javascript.

    - by Vladimir
    I'm sorting array: myArray.sort(comparators.some_comparator); and I have several comparator to choose from: comparators = { asc_firstname_comparator : function(o1, o2){ ... } desc_firstname_comparator : function(o1, o2){ ... } etc... } I want to write function which returns certain comparator depending on input data. It should figure out comparator from string inputs, something like this: function chooseComparator(field, order){ return "comparators."+order+"_"+field+"_comparator"; } So is it possible to pass only function name string to sort() method or I'll need to pass reference to correct comparator somehow?

    Read the article

  • Error Handling in T-SQL Scalar Function

    - by hydroparadise
    Ok.. this question could easily take multiple paths, so I will hit the more specific path first. While working with SQL Server 2005, I'm trying to create a scalar funtion that acts as a 'TryCast' from varchar to int. Where I encounter a problem is when I add a TRY block in the function; CREATE FUNCTION u_TryCastInt ( @Value as VARCHAR(MAX) ) RETURNS Int AS BEGIN DECLARE @Output AS Int BEGIN TRY SET @Output = CONVERT(Int, @Value) END TRY BEGIN CATCH SET @Output = 0 END CATCH RETURN @Output END Turns out theres all sorts of things wrong with this statement including "Invalid use of side-effecting or time-dependent operator in 'BEGIN TRY' within a function" and "Invalid use of side-effecting or time-dependent operator in 'END TRY' within a function". I can't seem to find any examples of using try statements within a scalar function, which got me thinking, is error handling in a function is possible? The goal here is to make a robust version of the Convert or Cast functions to allow a SELECT statement carry through depsite conversion errors. For example, take the following; CREATE TABLE tblTest ( f1 VARCHAR(50) ) GO INSERT INTO tblTest(f1) VALUES('1') INSERT INTO tblTest(f1) VALUES('2') INSERT INTO tblTest(f1) VALUES('3') INSERT INTO tblTest(f1) VALUES('f') INSERT INTO tblTest(f1) VALUES('5') INSERT INTO tblTest(f1) VALUES('1.1') SELECT CONVERT(int,f1) AS f1_num FROM tblTest DROP TABLE tblTest It never reaches point of dropping the table because the execution gets hung on trying to convert 'f' to an integer. I want to be able to do something like this; SELECT u_TryCastInt(f1) AS f1_num FROM tblTest fi_num __________ 1 2 3 0 5 0 Any thoughts on this? Is there anything that exists that handles this? Also, I would like to try and expand the conversation to support SQL Server 2000 since Try blocks are not an option in that scenario. Thanks in advance.

    Read the article

  • Get a JQuery function to execute after and independently of onLoad

    - by lewicki
    Is is possible to execute a JQuery function by injecting it into the page? IT CAN'T be attached to the .ready function. The reason is that the user will be uploading an image via iframe. I need JCrop to execute after I display the uploaded image. echo "<script>$('#pictures_step1_right_bottom1', window.parent.document).html('<img id=\"cropbox\" src=\"../../box/" . 'THM' . $filenameAlt . '.jpg' . "\">');</script>"; echo "<script>jQuery(function(){jQuery('#cropbox').Jcrop();});</script>"; This is executed in the iframe that is processing the image. it then sends it to the main page. This does not work however. EDIT: Ended up running a timer: function checkPic() { if($('#cropbox1').length != 0) { jQuery(function() { jQuery('#cropbox1').Jcrop(); }); } timer(); // Check size again after 1 second } function timer(){ var myTimer = setTimeout('checkPic()', 3000); // Check size every 1 second}

    Read the article

  • Function inside jquery returns undefined

    - by steamboy
    Hello Guys, The function I called inside jquery returns undefined. I checked the function and it returns correct data when I firebugged it. function addToPlaylist(component_type,add_to_pl_value,pl_list_no) { add_to_pl_value_split = add_to_pl_value.split(":"); $.ajax({ type: "POST", url: "ds/index.php/playlist/check_folder", data: "component_type="+component_type+"&value="+add_to_pl_value_split[1], success: function(msg) { if(msg == 'not_folder') { if(component_type == 'video') { rendered_item = render_list_item_video(add_to_pl_value_split[0],add_to_pl_value_split[1],pl_list_no) } else if(component_type == 'image') { rendered_item = render_list_item_image(add_to_pl_value_split[0],add_to_pl_value_split[1],pl_list_no) } } else { //List files from folder folder_name = add_to_pl_value_split[1].replace(' ','-'); var x = msg; // json eval('var file='+x); var rendered_item; for ( var i in file ) { //console.log(file[i]); if(component_type == 'video') { rendered_item = render_list_item_video(folder_name+'-'+i,file[i],pl_list_no) + rendered_item; } if(component_type == 'image') { rendered_item = render_list_item_image(folder_name+'-'+i,file[i],pl_list_no) + rendered_item; } } } $("#files").html(filebrowser_list); //Reload Playlist console.log(rendered_item); return rendered_item; }, error: function() { alert("An error occured while updating. Try again in a while"); } }) } $('document').ready(function() { addToPlaylist($('#component_type').val(),ui_item,0); //This one returns undefined });

    Read the article

  • How to use include within a function?

    - by mahks
    I have a large function that I wish to load only when it is needed. So I assume using include is the way to go. But I need several support functions as well -only used in go_do_it(). If they are in the included file I get a redeclare error. See example A If I place the support functions in an include_once it works fine, see Example B. If I use include_once for the func_1 code, the second call fails. -func_1 needs include -func_2 needs include_once Why does does include_once fail for func_1, does it get reloaded each time the function is called? Example A: <?php /* main.php */ go_do_it(); go_do_it(); function go_do_it(){ include 'func_1.php'; } ?> <?php /* func_1.php */ echo '<br>Doing it'; nested_func() function nested_func(){ echo ' in nest'; } ?> Example B: <?php /* main.php */ go_do_it(); go_do_it(); function go_do_it(){ include_once 'func_2.php'; include 'func_1.php'; } ?> <?php /* func_1.php */ echo '<br> - doing it'; nested_func(); ?> <?php /* func_2.php */ function nested_func(){ echo ' in nest'; } ?>

    Read the article

  • function in php for displaying a menu

    - by Stanislas Piotrowski
    I met some trouble with a function I have written. In fact I have an array in which I have different custom values. I would like to display the result of that, so here is my function function getAccess($var){ $data=mysql_fetch_array(mysql_query("SELECT * FROM `acces` WHERE `id`='.$var.'")); return $data; } getAccess($_SESSION['id']); $paramAcces = array( 'comptesfinanciers' => array( 'libelle' => 'COMPTES FINANCIERS', 'acces' => $data['comptesfinanciers'], 'lien' => 'financier', 'image' => 'images/finances.png' ) ); I have done a var_dump of $paramAcces which return array(1) { ["comptesfinanciers"]=> array(4) { ["libelle"]=> string(18) "COMPTES FINANCIERS" ["acces"]=> NULL ["lien"]=> string(9) "financier" ["image"]=> string(19) "images/finances.png" } } (that are the ecpected values). Here is the function for displaying what is in the array /** * AFFICHAGE DE LA SECTION PARAMETRES SUR LA PAGE D'ACCUEIL */ function affichParam($paramAccees){ echo '<ul class="getcash-vmenu"><li><a href="index.php?p='.$paramAccees['lien'].'" class="active"><span class="t"><img src="'.$paramAccees['image'].'"> '.$paramAccees['libelle'].'</span></a></li></ul>'; } The trouble is that actualy it return to me an empty line. I really do not know what I'm wrong doin: I call the function like that: <?php affichParam($paramAccees) ?> In a second time I will add more value, so I think I will have to do a for each loop or something like that. But actualy I just would like to display the first record. Any kind of help will be much apprecitaed

    Read the article

  • function php with parameter 0

    - by Arnaud Ncy
    I have a function like this public function get_page($position) { switch ($position) { case "current": echo "current"; return $this->current_page; break; case "first": echo "first"; return $this->current_page >= 3 ? 1 : false; break; case "last": echo "last"; return $this->current_page <= $this->total_pages() - 2 ? ceil($this->count / $this->nb_items_to_show) : false; break; case "previous": echo "previous"; return $this->current_page - 1 >= 1 ? $this->current_page - 1 : false; break; case "next": echo "next"; return $this->current_page + 1 <= $this->total_pages() ? $this->current_page + 1 : false; break; case is_int($position): echo "int"; if ($position >= 1 && $position <= $this->total_pages()) { return $position; } else { return false; } break; default: echo "default"; return false; break; } } When I call the function, it works for every parameters except 0 and goes in "current" case in the switch. $paginator->get_page(0); If I call the function with quotes "0", it works. But the function could be called like this $paginator->get_page($paginator->get_page("current") - 2); How can I call the function with parameter 0 ?

    Read the article

  • Classic ASP Recursive function

    - by user333411
    Hi everyone, I havent done any classic ASP for a couple of years and now trying to get back into it from c# is prooving impossible! I've got a recursive function which very simply is supposed to query a database based on a value passed to the function and once the function has stopped calling itself it returns the recordset....however im getting the old error '80020009' message. I've declared the recordset outside of the function. Cany anyone see the error in my ways? Dim objRsTmp Function buildList(intParentGroupID) Set objRsTmp = Server.CreateObject("Adodb.Recordset") SQLCommand = "SELECT * FROM tblGroups WHERE tblGroups.intParentGroupID = " & intParentGroupID & ";" objRsTmp.Open SQLCommand, strConnection, 3, 3 If Not objRsTmp.Eof Then While Not objRsTmp.Eof Response.Write(objRsTmp("strGroup") & "<br />") buildList(objRsTmp("intID")) objRsTmp.MoveNext Wend End If Set buildList = objRsTmp '#objRsTmp.Close() 'Set objRsTmp = Nothing End Function Set objRs = buildList(0) If Not objRs.Eof Then Response.Write("There are records") While Not objRs.Eof For Each oFld in objRs.Fields Response.Write(oFld.Name & ": " & oFld.Value & ",") next Response.Write("<br />") objRs.MoveNext Wend End If Any assistance would be greatly appreciated. Regards, Al

    Read the article

  • Created function not found

    - by skerit
    I'm trying to create a simple function, but at runtime firebug says the function does not exist. Here's the function code: <script type="text/javascript"> function load_qtip(apply_qtip_to) { $(apply_qtip_to).each(function(){ $(this).qtip( { content: { // Set the text to an image HTML string with the correct src URL to the loading image you want to use text: '<img class="throbber" src="/projects/qtip/images/throbber.gif" alt="Loading..." />', url: $(this).attr('rel'), // Use the rel attribute of each element for the url to load title: { text: 'Nieuwsbladshop.be - ' + $(this).attr('tooltip'), // Give the tooltip a title using each elements text //button: 'Sluiten' // Show a close link in the title } }, position: { corner: { target: 'bottomMiddle', // Position the tooltip above the link tooltip: 'topMiddle' }, adjust: { screen: true // Keep the tooltip on-screen at all times } }, show: { when: 'mouseover', solo: true // Only show one tooltip at a time }, hide: 'mouseout', style: { tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner border: { width: 0, radius: 4 }, name: 'light', // Use the default light style width: 250 // Set the tooltip width } }) } } </script> And I'm trying to call it here: <script type="text/javascript"> // Create the tooltips only on document load $(document).ready(function() { load_qtip('#shopcarousel a[rel]'); // Use the each() method to gain access to each elements attributes }); </script> What am I doing wrong?

    Read the article

  • C Programming: malloc() inside another function

    - by vikramtheone
    Hi Guys, I need help with malloc() inside another function. I'm passing a pointer and size to the function from my main() and I would like to allocate memory for that pointer dynamically using malloc() from inside that called function, but what I see is that.... the memory which is getting allocated is for the pointer declared withing my called function and not for the pointer which is inside the main(). How should I pass a pointer to a function and allocate memory for the passed pointer from inside the called function? Can anyone throw light on this? Help!!! Vikram I have written the following code and I get the output as shown below SOURCE: main() { unsigned char *input_image; unsigned int bmp_image_size = 262144; if(alloc_pixels(input_image, bmp_image_size)==NULL) printf("\nPoint2: Memory allocated: %d bytes",_msize(input_image)); else printf("\nPoint3: Memory not allocated"); } signed char alloc_pixels(unsigned char *ptr, unsigned int size) { signed char status = NO_ERROR; ptr = NULL; ptr = (unsigned char*)malloc(size); if(ptr== NULL) { status = ERROR; free(ptr); printf("\nERROR: Memory allocation did not complete successfully!"); } printf("\nPoint1: Memory allocated: %d bytes",_msize(ptr)); return status; } PROGRAM OUTPUT: Point1: Memory allocated ptr: 262144 bytes Point2: Memory allocated input_image: 0 bytes

    Read the article

  • In ActionScript, is there a way to test for existence of variable with datatype "Function"

    - by Robusto
    So I have a class where I instantiate a variable callback like so: public var callback:Function; So far so good. Now, I want to add an event listener to this class and test for existence of the callback. I'm doing like so: this.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent) : void { if (callback) { // do some things } }); This works great, doesn't throw any errors, but everywhere I test for callback I get the following warning: 3553: Function value used where type Boolean was expected. Possibly the parentheses () are missing after this function reference. That bugged me, so I tried to get rid of the warning by testing for null and undefined. Those caused errors. I can't instantiate a Function as null, either. I know, I know, real programmers only care about errors, not warnings. I will survive if this situation is not resolved. But it bothers me! :) Am I just being neurotic, or is there actually some way to test whether a real Function has been created without the IDE bitching about it?

    Read the article

  • Javascript object binding problem inside of function prototype definitions

    - by Arion
    Hi all, I am trying to figure out the right place to bind a function prototype to be called later. The full code of the example can be found here: http://www.iprosites.com/jso/ My javascript example is very basic: function Obj(width, height){ this.width = width; this.height = height; } Obj.prototype.test = function(){ var xhr=init(); xhr.open('GET', '?ajax=test', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xhr.onreadystatechange = function() { if (xhr.responseText == '403') { window.location.reload(false); } if (xhr.readyState == 4 && xhr.status == 200) { this.response = parseResponse(xhr.responseText); document.getElementById('resp').innerHTML = this.response.return_value; this.doAnotherAction(); } }; xhr.send(); } Obj.prototype.doAnotherAction = function(){ alert('Another Action Done'); } var myo = new Obj(4, 6); If you try to run myo.test() in Firebug, you will get the "this.doAnotherAction is not a function" response. The 2 support functions init() and parseResponse() can be found in the test.js link if you wish to view them, but should not be too relevant to this problem. I've affirmed that this.doAnotherAction() thinks "this" is the XMLHttpResponse object as expected from an instanceof test. Can anyone help with some insight on direction with binding? Everything I've tried seems not to work! I do use Mootools, although the library is not present in this example. Thanks in advance, Arion

    Read the article

  • creating an object within a function of a program

    - by user1066524
    could someone please tell me what I need to do in order to create an object in a function. I will try to explain by making up some sort of example... Let's say I have a program named TimeScheduler.cpp that implements the class Schedule.h (and I have the implementation in a separate file Schedule.cpp where we define the methods). In the declaration file we have declared two constructors Schedule(); //the default and Schedule(int, int, int);//accepts three arguments to get to the point--let's say in the main program file TimeScheduler.cpp we created our own functions in this program apart from the functions inherited from the class Schedule. so we have our prototypes listed at the top. /*prototypes*/ void makeSomeTime(); etc..... we have main(){ //etc etc... } we then define these program functions void makeSomeTime(){ //process } let's say that inside the function makeSomeTime(), we would like to create an array of Schedule objects like this Schedule ob[]={ summer(5,14, 49), fall(9,25,50) }; what do I have to do to the function makeSomeTime() in order for it to allow me to create this array of objects. The reason I ask is currently i'm having difficulty with my own program in that it WILL allow me to create this array of objects in main()....but NOT in a function like I just gave an example of. The strange thing is it will allow me to create a dynamic array of objects in the function..... like Schedule *ob = new Schedule[n+1]; ob[2]= Schedule(x,y,z); Why would it let me assign to a non-dynamic array in main(), but not let me do that in the function?

    Read the article

  • Subsonic : Can’t decide which property to consider the Key? foreign key issue.

    - by AJ
    Hi I am trying to select count of rows from a table which has foreign keys of two tables. The C# code threw the error mentioned below. So, I added a primary key column to the table (schema as follows) and regenerated the code. But still the same error is coming. Error : Can't decide which property to consider the Key - you can create one called 'ID' or mark one with SubSonicPrimaryKey attribute sqLite Table schema CREATE TABLE "AlbumDocuments" ("Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "AlbumId" INTEGER NOT NULL CONSTRAINT fk_AlbumId REFERENCES Albums(Id) , "DocumentId" INTEGER NOT NULL CONSTRAINT fk_DocumentId REFERENCES Documents(Id)) C# code int selectAlbumDocumentsCount = new SubSonic.Query.Select() .From<DocSafeDB.DataLayer.AlbumDocumentsTable>() .Where(DocSafeDB.DataLayer.AlbumDocumentsTable.AlbumIdColumn).In(request.AlbumId) .Execute(); Not sure what I should be doing next as I can't do where against primary key because I don;t have that info. So my questions are: How do I select count of rows against foreign key column? Is primary key required in this scenario? I have several things but not sure why its not working. To me it looks like a very normal use case. Please advise. Thanks AJ

    Read the article

  • MYSQL inserting records form table A into tables B and C (linked by foreign key) depending on column values in table A

    - by Chez
    Hi All, Have been searching high and low for a simple solution to a mysql insert problem. The problem is as follows: I am putting together an organisational database consisting of departments and desks. A department may or may not have n number of desks. Both departments and desks have their own table linked by a foreign key in desks to the relevant record in departments (i.e. the pk). I have a temporary table which I use to place all new department data (n records long)...In this table n number of desk records for a department follow the department record directly below. In the TEMP table, if a column department_name has a value,it is a department, if it doesn't it will have a value for the column desk and therefore will be a desk which is related to the above department. As I said there maybe several desk records until you get to the next department record. Ok, so what I want to do is the following: Insert the departments into the departments table and its desks into the desks table , generating a foreign key in the desk record to the relevant departments id. In pseudo-ish code: for each record in TEMP table if Department INSERT the record into Departments get the id of the newly created Department record and store it somewhere else if Desk INSERT the desk into the desks table with the relevant departments id as the foreignkey note once again that all departments desks directly follow the department in the TEMP Table Many Thanks

    Read the article

  • Ajax-based data loading using jQuery.load() function in ASP.NET

    - by hajan
    In general, jQuery has made Ajax very easy by providing low-level interface, shorthand methods and helper functions, which all gives us great features of handling Ajax requests in our ASP.NET Webs. The simplest way to load data from the server and place the returned HTML in browser is to use the jQuery.load() function. The very firs time when I started playing with this function, I didn't believe it will work that much easy. What you can do with this method is simply call given url as parameter to the load function and display the content in the selector after which this function is chained. So, to clear up this, let me give you one very simple example: $("#result").load("AjaxPages/Page.html"); As you can see from the above image, after clicking the ‘Load Content’ button which fires the above code, we are making Ajax Get and the Response is the entire page HTML. So, rather than using (old) iframes, you can now use this method to load other html pages inside the page from where the script with load function is called. This method is equivalent to the jQuery Ajax Get method $.get(url, data, function () { }) only that the $.load() is method rather than global function and has an implicit callback function. To provide callback to your load, you can simply add function as second parameter, see example: $("#result").load("AjaxPages/Page.html", function () { alert("Page.html has been loaded successfully!") }); Since load is part of the chain which is follower of the given jQuery Selector where the content should be loaded, it means that the $.load() function won't execute if there is no such selector found within the DOM. Another interesting thing to mention, and maybe you've asked yourself is how we know if GET or POST method type is executed? It's simple, if we provide 'data' as second parameter to the load function, then POST is used, otherwise GET is assumed. POST $("#result").load("AjaxPages/Page.html", { "name": "hajan" }, function () { ////callback function implementation });   GET $("#result").load("AjaxPages/Page.html", function () { ////callback function implementation });   Another important feature that $.load() has ($.get() does not) is loading page fragments. Using jQuery's selector capability, you can do this: $("#result").load("AjaxPages/Page.html #resultTable"); In our Page.html, the content now is: So, after the call, only the table with id resultTable will load in our page.   As you can see, we have loaded only the table with id resultTable (1) inside div with id result (2). This is great feature since we won't need to filter the returned HTML content again in our callback function on the master page from where we have called $.load() function. Besides the fact that you can simply call static HTML pages, you can also use this function to load dynamic ASPX pages or ASP.NET ASHX Handlers . Lets say we have another page (ASPX) in our AjaxPages folder with name GetProducts.aspx. This page has repeater control (or anything you want to bind dynamic server-side content) that displays set of data in it. Now, I want to filter the data in the repeater based on the Query String parameter provided when calling that page. For example, if I call the page using GetProducts.aspx?category=computers, it will load only computers… so, this will filter the products automatically by given category. The example ASPX code of GetProducts.aspx page is: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetProducts.aspx.cs" Inherits="WebApplication1.AjaxPages.GetProducts" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <table id="tableProducts"> <asp:Repeater ID="rptProducts" runat="server"> <HeaderTemplate> <tr> <th>Product</th> <th>Price</th> <th>Category</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td> <%# Eval("ProductName")%> </td> <td> <%# Eval("Price") %> </td> <td> <%# Eval("Category") %> </td> </tr> </ItemTemplate> </asp:Repeater> </ul> </div> </form> </body> </html> The C# code-behind sample code is: public partial class GetProducts : System.Web.UI.Page { public List<Product> products; protected override void OnInit(EventArgs e) { LoadSampleProductsData(); //load sample data base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString.Count > 0) { if (!string.IsNullOrEmpty(Request.QueryString["category"])) { string category = Request.QueryString["category"]; //get query string into string variable //filter products sample data by category using LINQ //and add the collection as data source to the repeater rptProducts.DataSource = products.Where(x => x.Category == category); rptProducts.DataBind(); //bind repeater } } } //load sample data method public void LoadSampleProductsData() { products = new List<Product>(); products.Add(new Product() { Category = "computers", Price = 200, ProductName = "Dell PC" }); products.Add(new Product() { Category = "shoes", Price = 90, ProductName = "Nike" }); products.Add(new Product() { Category = "shoes", Price = 66, ProductName = "Adidas" }); products.Add(new Product() { Category = "computers", Price = 210, ProductName = "HP PC" }); products.Add(new Product() { Category = "shoes", Price = 85, ProductName = "Puma" }); } } //sample Product class public class Product { public string ProductName { get; set; } public decimal Price { get; set; } public string Category { get; set; } } Mainly, I just have sample data loading function, Product class and depending of the query string, I am filtering the products list using LINQ Where statement. If we run this page without query string, it will show no data. If we call the page with category query string, it will filter automatically. Example: /AjaxPages/GetProducts.aspx?category=shoes The result will be: or if we use category=computers, like this /AjaxPages/GetProducts.aspx?category=computers, the result will be: So, now using jQuery.load() function, we can call this page with provided query string parameter and load appropriate content… The ASPX code in our Default.aspx page, which will call the AjaxPages/GetProducts.aspx page using jQuery.load() function is: <asp:RadioButtonList ID="rblProductCategory" runat="server"> <asp:ListItem Text="Shoes" Value="shoes" Selected="True" /> <asp:ListItem Text="Computers" Value="computers" /> </asp:RadioButtonList> <asp:Button ID="btnLoadProducts" runat="server" Text="Load Products" /> <!-- Here we will load the products, based on the radio button selection--> <div id="products"></div> </form> The jQuery code: $("#<%= btnLoadProducts.ClientID %>").click(function (event) { event.preventDefault(); //preventing button's default behavior var selectedRadioButton = $("#<%= rblProductCategory.ClientID %> input:checked").val(); //call GetProducts.aspx with the category query string for the selected category in radio button list //filter and get only the #tableProducts content inside #products div $("#products").load("AjaxPages/GetProducts.aspx?category=" + selectedRadioButton + " #tableProducts"); }); The end result: You can download the code sample from here. You can read more about jQuery.load() function here. I hope this was useful blog post for you. Please do let me know your feedback. Best Regards, Hajan

    Read the article

  • Determine whether a link points to a file on local host or foreign domain [migrated]

    - by user107157
    This has been a burning question for me ever since and I think it's interesting enough to discuss it on the forums. As most will know, in websites we include anchor links, stylesheets, script files (javascript) and images. For anchor links we use the form <a href="..." /> For stylesheets we may use the form <link rel="stylesheet" type="text/css" href="..." /> For javascript we may use <script src="..." /> For images we use <img src="..." /> So, the question is this: How do we know that what is in the link pointer (i.e. replacing the ... in each example) is a local file or a foreign entity? To make it clear, lets say I create a local file named "ashish.com". Now, my purpose is to create a link so that anybody who clicks on it may download it. So, my code would be thus: <a href="ashish.com">Download It</a> But this makes it ambiguous. I could also be referring to a website named "ashish.com" So, how does the computer magically know which one I mean? Or does it even know this? What would happen in such a scenario?

    Read the article

  • Is this postgres function cost efficient or still have to clean

    - by kiranking
    There are two tables in postgres db. english_all and english_glob First table contains words like international,confidential,booting,cooler ...etc I have written the function to get the words from english_all then perform for loop for each word to get word list which are not inserted in anglish_glob table. Word list is like I In Int Inte Inter .. b bo boo boot .. c co coo cool etc.. for some reason zwnj(zero-width non-joiner) is added during insertion to english_all table. But in function I am removing that character with regexp_replace. Postgres function for_loop_test is taking two parameter min and max based on that I am selecting words from english_all table. function code is like DECLARE inMinLength ALIAS FOR $1; inMaxLength ALIAS FOR $2; mviews RECORD; outenglishListRow english_word_list;--custom data type eng_id,english_text BEGIN FOR mviews IN SELECT id,english_all_text FROM english_all where wlength between inMinLength and inMaxLength ORDER BY english_all_text limit 30 LOOP FOR i IN 1..char_length(regexp_replace(mviews.english_all_text,'(?)$','')) LOOP FOR outenglishListRow IN SELECT distinct on (regexp_replace((substring(mviews.english_all_text from 1 for i)),'(?)$','')) mviews.id, regexp_replace((substring(mviews.english_all_text from 1 for i)),'(?)$','') where regexp_replace((substring(mviews.english_all_text from 1 for i)),'(?)$','') not in(select english_glob.english_text from english_glob where i=english_glob.wlength) order by regexp_replace((substring(mviews.english_all_text from 1 for i)),'(?)$','') LOOP RETURN NEXT outenglishListRow; END LOOP; END LOOP; END LOOP; END; Once I get the word list I will insert that into another table english_glob. My question is is there any thing I can add to or remove from function to make it more efficient. edit Let assume english_all table have words like footer,settle,question,overflow,database,kingdom If inMinLength = 5 and inmaxLength=7 then in the outer loop footer,settle,kingdom will be selected. For above 3 words inner two loop will apply to get words like f,fo,foo,foot,foote,footer,s,se,set,sett,settl .... etc. In the final process words which are bold will be entered into english_glob with another parameter like 1 to denote it is a proper word and stored in the another filed of english_glob table. Remaining word will be stored with another parameter 0 because in the next call words which are saved in database should not be fetched again. edit2: This is a complete code CREATE TABLE english_all ( id serial NOT NULL, english_all_text text NOT NULL, wlength integer NOT NULL, CONSTRAINT english_all PRIMARY KEY (id), CONSTRAINT english_all_kan_text_uq_id UNIQUE (english_all_text) ) CREATE TABLE english_glob ( id serial NOT NULL, english_text text NOT NULL, is_prop integer default 1, CONSTRAINT english_glob PRIMARY KEY (id), CONSTRAINT english_glob_kan_text_uq_id UNIQUE (english_text) ) insert into english_all(english_text) values ('ant'),('forget'),('forgive'); on function call with parameter 3 and 6 fallowing rows should fetched a an ant f fo for forg forge forget next is insert to another table based on above row insert into english_glob(english_text,is_prop) values ('a',1),('an',1), ('ant',1),('f',0), ('fo',0),('for',1), ('forg',0),('forge',1), ('forget',1), on function call next time with parameter 3 and 7 fallowing rows should fetched.(because f,fo,for,forg are all entered in english_glob table) forgi forgiv forgive

    Read the article

  • Call PHP Function in jQuery (var)

    - by l3gion
    Hello, I'm facing a small problem that I can't solve by myself. I have this php function: function intervalo_manha(){ $que="select id_intervalo,data_15 from intervalo_manha order by id_intervalo"; $re=mysql_query($que); $object.="<select>"; $object.="<option></option>"; while(list($id_intervalo, $data_15)=mysql_fetch_row($re)) { $object.= "<option value=\"".$id_intervalo."\">".$data_15."</option>"; } $object.="</select>"; return $object; } This function return a select with information from database. I also have this js function: $(document).ready(function() { var destTable = $("#dataTable"); $("#btnAdd").click(function() { var newRow = $("<tr style='margin-left:-60px'><td><INPUT type='checkbox' name='chk'/></td><td><INPUT type='text' name='txt[]' id='txt'/></td><td></td></tr>"); $("#dataTable").append(newRow); newRow.find('input').autocomplete("get_cols_name.php", { width: 260, matchContains: true, selectFirst: false }); }); }); This one will add a new row to my table, and for each new input will "activate" autocomplete. What I want to do is, instead of this: var newRow = $("<tr style='margin-left:-60px'><td><INPUT type='checkbox' name='chk'/></td><td><INPUT type='text' name='txt[]' id='txt'/></td><td></td></tr>"); I would like to have something like this: var newRow = $("<tr style='margin-left:-60px'><td><INPUT type='checkbox' name='chk'/></td><td><INPUT type='text' name='txt[]' id='txt'/></td><td><?php echo intervalo_manha(); ?></td></tr>"); Calling php function directly will return nothing, and I can't do anything. Is there any way to accomplish this? Thank you

    Read the article

  • Function returning a class containing a function returning a class

    - by Scott
    I'm working on an object-oriented Excel add-in to retrieve information from our ERP system's database. Here is an example of a function call: itemDescription = Macola.Item("12345").Description Macola is an instance of a class which takes care of database access. Item() is a function of the Macola class which returns an instance of an ItemMaster class. Description() is a function of the ItemMaster class. This is all working correctly. Items can be be stored in more than one location, so my next step is to do this: quantityOnHand = Macola.Item("12345").Location("A1").QuantityOnHand Location() is a function of the ItemMaster class which returns an instance of the ItemLocation class (well, in theory anyway). QuantityOnHand() is a function of the ItemLocation class. But for some reason, the ItemLocation class is not even being intialized. Public Function Location(inventoryLocation As String) As ItemLocation Set Location = New ItemLocation Location.Item = item_no Location.Code = inventoryLocation End Function In the above sample, the variable item_no is a member variable of the ItemMaster class. Oddly enough, I can successfully instantiate the ItemLocation class outside of the ItemMaster class in a non-class module. Dim test As New ItemLocation test.Item = "12345" test.Code = "A1" quantityOnHand = test.QuantityOnHand Is there some way to make this work the way I want? I'm trying to keep the API as simple as possible. So that it only takes one line of code to retrieve a value.

    Read the article

  • The Function Works But Reports this.refresh() is not a function

    - by ren1999
    I get this.refresh() is not a function in the error log every time I use this function but it works fine. Also, when I click on this function for the first time, this.value=undefined. When I click the function again in this form and every other form, the value populates just fine with the previous value. What could I be doing wrong? How do I write this function more efficiently? I still don't quite understand how to use this.value to capture and store a value within an array. Please notice that I added ---- where there should be a '----<' to be able to display the code. function askGender(x) {response="----select class=widgetstyle onClick=_setGender(this.value)----option value=FemaleFemale----option value=MaleMale"; characters[x].setGender(response); if(this.gender!=0) {response=this.gender; this.gender=0; characters[x].setGender(response); } } function _setGender(x) {this.gender=x; this.refresh(); }

    Read the article

  • How do I pass a variable number of parameters along with a callback function?

    - by Bungle
    I'm using a function to lazy-load the Sizzle selector engine (used by jQuery): var sizzle_loaded; // load the Sizzle script function load_sizzle(module_name) { var script; // load Sizzle script and set up 'onload' and 'onreadystatechange' event // handlers to ensure that external script is loaded before dependent // code is executed script = document.createElement('script'); script.src = 'sizzle.min.js'; script.onload = function() { sizzle_loaded = true; gather_content(module_name); }; script.onreadystatechange = function() { if ((script.readyState === 'loaded' || script.readyState === 'complete') && !sizzle_loaded) { sizzle_loaded = true; gather_content(module_name); } }; // append script to the document document.getElementsByTagName('head')[0].appendChild(script); } I set the onload and onreadystatechange event handlers, as well as the sizzle_loaded flag to call another function (gather_content()) as soon as Sizzle has loaded. All of this is needed to do this in a cross-browser way. Until now, my project only had to lazy-load Sizzle at one point in the script, so I was able to just hard-code the gather_content() function call into the load_sizzle() function. However, I now need to lazy-load Sizzle at two different points in the script, and call a different function either time once it's loaded. My first instinct was to modify the function to accept a callback function: var sizzle_loaded; // load the Sizzle script function load_sizzle(module_name, callback) { var script; // load Sizzle script and set up 'onload' and 'onreadystatechange' event // handlers to ensure that external script is loaded before dependent // code is executed script = document.createElement('script'); script.src = 'sizzle.min.js'; script.onload = function() { sizzle_loaded = true; callback(module_name); }; script.onreadystatechange = function() { if ((script.readyState === 'loaded' || script.readyState === 'complete') && !sizzle_loaded) { sizzle_loaded = true; callback(module_name); } }; // append script to the document document.getElementsByTagName('head')[0].appendChild(script); } Then, I could just call it like this: load_sizzle(module_name, gather_content); However, the other callback function that I need to use takes more parameters than gather_content() does. How can I modify my function so that I can specify a variable number of parameters, to be passed with the callback function? Or, am I going about this the wrong way? Ultimately, I just want to load Sizzle, then call any function that I need to (with any arguments that it needs) once it's done loading. Thanks for any help!

    Read the article

  • Primary key/foreign Key naming convention

    - by Jeremy
    In our dev group we have a raging debate regarding the naming convention for Primary and Foreign Keys. There's basically two schools of thought in our group: 1) Primary Table (Employee) Primary Key is called ID Foreign table (Event) Foreign key is called EmployeeID 2) Primary Table (Employee) Primary Key is called EmployeeID Foreign table (Event) Foreign key is called EmployeeID I prefer not to duplicate the name of the table in any of the columns (So I prefer option 1 above). Conceptually, it is consisted with a lot of the recommended practices in other languages, where you don't use the name of the object in its property names. I think that naming the foreign key EmployeeID (or Employee_ID might be better) tells the reader that it is the ID column of the Employee Table. Some others prefer option 2 where you name the primary key prefixed with the table name so that the column name is the same throughout the database. I see that point, but you now can not visually distinguish a primary key from a foreign key. Also, I think it's redundant to have the table name in the column name, because if you think of the table as an entity and a column as a property or attribute of that entity, you think of it as the ID attribute of the Employee, not the EmployeeID attribute of an employee. I don't go an ask my coworker what his PersonAge or PersonGender is. I ask him what his Age is. So like I said, it's a raging debate and we go on and on and on about it. I'm interested to get some new perspective.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >