Search Results

Search found 72 results on 3 pages for 'javscript'.

Page 1/3 | 1 2 3  | Next Page >

  • javscript smart array loop, need some help here

    - by Totty
    var _test1 = []; _test1[88] = 'sex'; _test1[1999990] = 'hey'; for(i = 0, length = _test1.length; i < length; i++){ if(_test1[i] == 'hey'){ alert(_test1.length); } } this takes a lot of time, and there are only 2 values. Is there any way to be faster? Or to use another system that index objects by a number and then loop them fast? thanks

    Read the article

  • How to transfer control from javscript to asp page from javascript

    - by junaid ahmed
    I am very new to .net. I searched and googled a lot but couldn't find the solution for my issue. I have a asp .net application, In my login page i only have user id field. When the user submits the button, i need to have a transitional asp page (page which user doesn't see but runs in background) which will run some javascript and transfer the control to either page a or page b based on some condition. How do i achieve this? How do i call a controller action from javscript in mvc architecture in .net

    Read the article

  • Set default form textfield value (webbrowser control/DOM Javscript)

    - by Khou
    Hi I would like my application to load a webpage and set default the form textfield value a predefine value. Requirements: -The application is a windows form, it is to use the web browser control, to load a web page. -Textfield values are define by within the application. -When textfield on the webpage matches the applications predefined elements, the predefine fixed value is set and can not be changed by the end user. Example If my application defines element "FirstName" equal to value "John", the text field for value for element "FirstName" will always equal "John" and this value can not be changed by the end user. Below is html/javascript code to perform this functionality, now how do I implement this in a windows form? (without having to modify the loaded webpage source code (if possible). HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>page title</title> <script script type="text/javascript" src="demo1.js"></script> </head> <body onload="def(document.someform, 'name', 'my default name value');"> <h2 style="color: #8e9182">test form title</h2> <form name="someform" id="someform_frm" action="#"> <table cellspacing="1"> <tr><td><label for="name">NameX: </label></td><td><input type="text" size="30" maxlength="155" name="name" onchange="def(document.someform, 'name', 'my default name value');"></td></tr> <tr><td><label for="name2">NameY: </label></td><td><input type="text" size="30" maxlength="155" name="name2"></td></tr> <tr><td colspan="2"><input type="button" name="submit" value="Submit" onclick="showFormData(this.form);" ></td></table> </form> </body> </html> JAVASCRIPT function def(oForm, element_name, def_txt) { oForm.elements[element_name].value = def_txt; }

    Read the article

  • Kohana and Javscript path

    - by Leonti
    Hi! I have a following Kohana setup: All my files are placed under 'public_html/koh' My js files are placed under 'public_html/koh/media/js/' I use html::script helper to include those javascript files which generates me following html code: In my js I access one of controllers like 'json/getsomething' (which is http://localhost/koh/json/getsomething). It works OK as long as I'm staying in top of the controller: http://localhost/koh/home When I go to 'http://localhost/koh/home/index' it renders the same page of course but 'json/getsomething' is not accessible from Javascript anymore. How can I solve this problem? Include Javascript using absolute path? Create a variable in js like var fullPath = 'http://localhost/koh/'? What is the best practice to do it? Leonti

    Read the article

  • Javscript closure questions

    - by Shuchun Yang
    While I was reading the book Javascript: The Good Parts. I can not understand the piece of code bellow: We can generalize this by making a function that helps us make memoized functions. The memoizer function will take an initial memo array and the fundamental function. It returns a shell function that manages the memo store and that calls the fundamental function as needed. We pass the shell function and the function's parameters to the fundamental function: var memoizer = function (memo, fundamental) { var shell = function (n) { var result = memo[n]; if (typeof result !== 'number') { result = fundamental(shell, n); memo[n] = result; } return result; }; return shell; }; We can now define fibonacci with the memoizer, providing the initial memo array and fundamental function: var fibonacci = memoizer([0, 1], function (test, n) { return test(n - 1) + test(n - 2); }); My question is what is the test function? When does it get defined and invoked? It seems very confusing to me. Also I think this statement: memo[n] = result; is useless. Please correct if I am wrong.

    Read the article

  • Javscript: creating div with absolute positioning

    - by citricsquid
    Hi, Just wondering if there's a way to position a div with absolute so that it ignores EVERYTHING else, if my site clears floats it seems divs that are created with javascript and absolute positioning are still effected by it, is there any way to make them ignore EVERYTHING else and go exactly where I set them, regardless?

    Read the article

  • javscript delay output

    - by tazim
    I have written some code to display server's current date and time on browser every time user clicks the button . I have done this using ajax in django with the help of jquery. Now my, problem is I have to continously display the date and time once the button is clicked . Some Sample code or utilities allowing such kind of delay will be helpful . Thanks in advance The template is : $(document).ready(function() { $("button").click(function() { $.ajax({ type: "POST", url :"/showdate/", datatype: "json ", success : function(data){ var s = data.currentdate; var sd = s $(sd).appendTo("div"); } }); }); }); <button type="button">Click Me</button> <div id="someid"></div> The view function is : def showdate(request): now = datetime.datetime.now() string_now = str(now) return_dict = {'currentdate':string_now} json = simplejson.dumps(return_dict) return HttpResponse(json,mimetype="application/json")

    Read the article

  • object not found error with dynamic web forms with (jquery) javscript script

    - by deostroll
    In a normal aspx page I've set up a jquery tab system. When a particular tab shows up I wire up an ajax call to get another html page with the following content. It is simply a form with some javascript inside of it. <!-- demo.htm --> <form method="post" action="post.aspx"> <div id="fields"> Class: <input id="txtclass" name="txtclass" type="text"/> Grade: <input id="txtgrade" name="txtgrade" type="text"/> <input id="btnupdate" value="Update"/> </div> <div id="update"> Reason:<br/> <input id="txtreason" name="txtreason" type="text"/> <br/> Comments:<br/> <textarea id="txtcomments" name="txtcomments"></textarea> <br/> <input type="button" id="btnsave" value="Save"/> </div> <script type="text/javascript"> $(function(){ //all textboxes should be disabled $('#fields input').each(function(i,j){ if(! $(this).is(':button') ) $(this).attr('disabled', 'disabled') }); //update div should be hidden $('#update).hide(); //click event of btnupdate should // be set to show the update div contents // and enable input fields $('#btnupdate').click(function(){ //enable all textboxes $('#fields input').each(function(i,j){ $(this).attr('disabled', ''); }); //hide btnupdate $('#btnupdate').hide(); //show div update $('#update').show(); }); }); </script> </form> The script executes normally and the form is shown as intended. The btnupdate is supposed to show the contents in the update div and load the form for accepting user input. Whenever I hit btnupdate button I get an object not found exception on IE 8. IE 8 asks if it should start up its in-built debuggger. But, even in this debugger I cannot see what the problem is...However on clicking "No" in that dialog the button click function executes properly, and the form is displayed as intended. Is there a better way to resolve the problem?

    Read the article

  • Passing an ActionScript JPG Byte Array to Javscript (and eventually to PHP)

    - by Gus
    Our web application has a feature which uses Flash (AS3) to take photos using the user's web cam, then passes the resulting byte array to PHP where it is reconstructed and saved on the server. However, we need to be able to take this web application offline, and we have chosen Gears to do so. The user takes the app offline, performs his tasks, then when he's reconnected to the server, we "sync" the data back with our central database. We don't have PHP to interact with Flash anymore, but we still need to allow users to take and save photos. We don't know how to save a JPG that Flash creates in a local database. Our hope was that we could save the byte array, a serialized string, or somehow actually persist the object itself, then pass it back to either PHP or Flash (and then PHP) to recreate the JPG. We have tried: - passing the byte array to Javascript instead of PHP, but javascript doesn't seem to be able to do anything with it (the object seems to be stripped of its methods) - stringifying the byte array in Flash, and then passing it to Javascript, but we always get the same string: ÿØÿà Now we are thinking of serializing the string in Flash, passing it to Javascript, then on the return route, passing that string back to Flash which will then pass it to PHP to be reconstructed as a JPG. (whew). Since no one on our team has extensive Flash background, we're a bit lost. Is serialization the way to go? Is there a more realistic way to do this? Does anyone have any experience with this sort of thing? Perhaps we can build a javascript class that is the same as the byte array class in AS?

    Read the article

  • Javscript filter vs map problem

    - by graham.reeds
    As a continuation of my min/max across an array of objects I was wondering about the performance comparisons of filter vs map. So I put together a test on the values in my code as was going to look at the results in FireBug. This is the code: var _vec = this.vec; min_x = Math.min.apply(Math, _vec.filter(function(el){ return el["x"]; })); min_y = Math.min.apply(Math, _vec.map(function(el){ return el["x"]; })); The mapped version returns the correct result. However the filtered version returns NaN. Breaking it out, stepping through and finally inspecting the results, it would appear that the inner function returns the x property of _vec but the actual array returned from filter is the unfiltered _vec. I believe my usage of filter is correct - can anyone else see my problem?

    Read the article

  • Just a small problem regarding javscript BOM question

    - by caramel1991
    The question is this: Create a page with a number of links. Then write code that fires on the window onload event, displaying the href of each of the links on the page. And this is my solution <html> <body language="Javascript" onload="displayLink()"> <a href="http://www.google.com/">First link</a> <a href="http://www.yahoo.com/">Second link</a> <a href="http://www.msn.com/">Third link</a> <script type="text/javascript" language="Javascript"> function displayLink() { for(var i = 0;document.links[i];i++) { alert(document.links[i].href); } } </script> </body> </html> This is the answer provided by the book <html> <head> <script language=”JavaScript” type=”text/javascript”> function displayLinks() { var linksCounter; for (linksCounter = 0; linksCounter < document.links.length; linksCounter++) { alert(document.links[linksCounter].href); } } </script> </head> <body onload=”displayLinks()”> <A href=”link0.htm” >Link 0</A> <A href=”link1.htm”>Link 2</A> <A href=”link2.htm”>Link 2</A> </body> </html> Before I get into the javascript tutorial on how to check user browser version or model,I was using the same method as the example,by acessing the length property of the links array for the loop,but after I read through the tutorial,I find out that I can also use this alternative ways,by using the method that the test condition will evalute to true only if the document.links[i] return a valid value,so does my code is written using the valid method??If it's not,any comment regarding how to write a better code??Correct me if I'm wrong,I heard some of the people say "a good code is not evaluate solely on whether it works or not,but in terms of speed,the ability to comprehend the code,and could posssibly let others to understand the code easily".Is is true??

    Read the article

  • Address String Split in javscript

    - by Arasoi
    Ok folks I have bombed around for a few days trying to find a good solution for this one. What I have is two possible address formats. 28 Main St Somecity, NY 12345-6789 or Main St Somecity, Ny 12345-6789 What I need to do Is split both strings down into an array structured as such address[0] = HousNumber address[1] = Street address[2] = City address[3] = State address[4] = ZipCode My major problem is how to account for the lack of a house number. with out having the whole array shift the data up one. address[0] = Street address[1] = City address[2] = State address[3] = ZipCode [Edit] For those that are wondering this is what i am doing atm . (cleaner version) place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]); FCmap.setCenter(point,12); var a = place.address.split(','); var e = a[2].split(" "); var x = a[0].split(" "); var hn = x.filter(function(item,index){ return index == 0; }); var st = x.filter(function(item,index){ return index != 0; }); var street = ''; st.each(function(item,index){street += item + ' ';}); results[0] = new Hash({ FullAddie: place.address, HouseNum: hn[0], Dir: '', Street: street, City: a[1], State: e[1], ZipCode: e[2], GPoint: new GMarker(point), Lat: place.Point.coordinates[1], Lng: place.Point.coordinates[0] }); // End Address Splitting

    Read the article

  • Looking for Google Reader javscript commands for controlling events

    - by JayCrossler
    I've played in the /reader/ui/ code for a few hours now, and couldn't figure this out. Also, I didn't see any exact help when searching StackOverflow. This is really a JavaScript un-obfuscator question. I'm looking for a way to call the obfuscated Google Reader javascript commands... and am having trouble determining what actual function is called when the "Next Items" button is pressed or the spacebar is hit. I've tried using Firebug as well as FireEvents to track it down, but it's just too well hidden. Any ideas? Something that I could type into the URL bar and make it run, something like 'javascript:SH("entries-down", "click");void(0);' Thanks in advance! And, please let me know if it's against Google's terms of service to de-obfuscate their code to view these JavaScript commands.

    Read the article

  • Javscript REGEX

    - by Rabbott
    I need a javascript REGEX to check that the length of the string is 9 characters. Starts with 'A' or 'a' and is followed by 8 digits. Axxxxxxxx or axxxxxxxx

    Read the article

  • how to call the javscript funtion ontable row click

    - by kumar
    hi, I have a javascript funtion.. <script type="text/javascript"> var RowClick = function() { $("#mytable").click( $("#showgrid").load('/Products/List/Items/')); }; </script> Can I call this funtion on onclick evnt on tr? I am calling soemthing like this? <tr class="something" onclick="javascript:RowClick()');"> can i call like this? if I call its not loading the URL? can anybody help me out? thanks

    Read the article

  • how to call the javscript funtion on table row click

    - by kumar
    hi, I have a javascript function.. <script type="text/javascript"> var RowClick = function() { $("#mytable").click( $("#showgrid").load('/Products/List/Items/')); }; </script> Can I call this function on onclick event on tr? I am calling something like this? <tr class="something" onclick="javascript:RowClick()');"> can i call like this? if I call its not loading the URL? can anybody help me out? thanks

    Read the article

  • second external javscript file not loaded

    - by YsoL8
    Hi I have these lines in my html head section <script type="text/javascript" src="../behaviour/location.js"></script> <script type="text/javascript" src="../behaviour/ajax.js"></script> When I use either in isolation, the code in the external files executes as expected. However, when I use both, I find that neither works correctly. What do I need to do to fix this?

    Read the article

  • Javscript passing and using that function

    - by Totty
    I have: var f1 = function(a){ alert(a) } var f2 = function(data, method){ method(data) // the problem is here, // the method f1 is not called. Is there a way to call that method f1? // the method f1 might not be in this scope, the method f1 can // be in a class or like this... } f2(a, f1) The question is: Is there a way to call that f1 from f2, from the passed method? thanks

    Read the article

  • django templates array assignment

    - by Hulk
    The following is in views: rows=query.evaluation_set.all() row_arr = [] for row in rows: row_arr.append(row.row_details) dict.update({'row_arr' : row_arr ,'col_arr' : col_arr}) return render_to_response('valuemart/show.html',context_instance=RequestContext(request,{'dict': dict})) How to extract the row_Arr array in the templates in javascript and list out all its values.row_Arr contains data of a column <script> var row_arr = '{{dict.row_arr}}'; //extract values here </script> Thanks..

    Read the article

  • safely encode and pass a string from a html link to PHP program

    - by bert
    What series of steps would be reqired to safely encode and pass a string from a html href using javascript to construct the link to a php program. in javascript set up URL // encodes a URI component. path = "mypgm.php?from=" + encodeURIComponent(myvar) ; in php: // get passed variables $myvar = isset($_GET['myvar']) ? ($_GET['myvar']) : ''; // decode - (make the string readable) $myvar = (rawurldecode($myvar)); // converts characters to HTML entities (reduce risk of attack) $myvar = htmlentities($myvar); // maybe custom sanitize program as well? // see [http://stackoverflow.com/questions/2668854/php-sanitizing-strings-to-make-them-url-and-filename-safe][1] $myvar = sanitize($myvar);

    Read the article

  • pdf download option should appear

    - by tibin mathew
    Hi, I need some code to download a pdf file. what i mean is normaly when we give like this href="./downloads/Intake Sheet rev 4-1-10.pdf" that will open the pdf in the same window, i dont want this , i need that to be downloaded , means need the download window to appear. i'm using php to develop my website. Please give me some idea. Thanks

    Read the article

1 2 3  | Next Page >