Search Results

Search found 25050 results on 1002 pages for 'javascript oop'.

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

  • javascript select box hanging on second select in ie7

    - by bsandrabr
    I have a drop down select box inside a div. When the user clicks on change, a dropdown box appears next to the change/submit button and the user makes a selection which then updates the db and the selection appears instead of the dropdown. All works fine in IE8 and firefox but in IE7 it allows one selection (there are several identical dropdowns) but the second time a selection is made it hangs on please wait. This is the relevant code <td width=200> <input type="button" onclick="startChanging(this)" value="Change" /></td> <script type="text/javascript"> var selectBox, isEditing = false; var recordvalue; if( window.XMLHttpRequest ) { recordvalue = new XMLHttpRequest(); } else if( window.ActiveXObject ) { try { recordvalue = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {} } window.onload = function () { selectBox = document.getElementById('changer'); selectBox.id = ''; selectBox.parentNode.removeChild(selectBox); }; function startChanging(whatButton) { if( isEditing && isEditing != whatButton ) { return; } //no editing of other entries if( isEditing == whatButton ) { changeSelect(whatButton); return; } //this time, act as "submit" isEditing = whatButton; whatButton.value = 'Submit'; var theRow = whatButton.parentNode.parentNode; var stateCell = theRow.cells[3]; //the cell that says "present" stateCell.className = 'editing'; //so you can use CSS to remove the background colour stateCell.replaceChild(selectBox,stateCell.firstChild); //PRESENT is replaced with the select input selectBox.selectedIndex = 0; } function changeSelect(whatButton) { isEditing = true; //don't allow it to be clicked until submission is complete whatButton.value = 'Change'; var stateCell = selectBox.parentNode; var theRow = stateCell.parentNode; var editid = theRow.cells[0].firstChild.firstChild.nodeValue; //text inside the first cell var value = selectBox.firstChild.options[selectBox.firstChild.selectedIndex].value; //the option they chose selectBox.parentNode.replaceChild(document.createTextNode('Please wait...'),selectBox); if( !recordvalue ) { //allow fallback to basic HTTP location.href = 'getupdate.php?id='+editid+'&newvalue='+value; } else { recordvalue.onreadystatechange = function () { if( recordvalue.readyState != 4 ) { return; } if( recordvalue.status >= 300 ) { alert('An error occurred when trying to update'); } isEditing = false; newState = recordvalue.responseText.split("|"); stateCell.className = newState[0]; stateCell.firstChild.nodeValue = newState[1] || 'Server response was not correct'; }; recordvalue.open('GET', "getupdate.php?id="+editid+"&newvalue="+value, true); recordvalue.send(null); } } </script> If anyone has any idea why this is happening I'd be very grateful

    Read the article

  • Javascript not getting keyDown input

    - by William
    For some reason my code just isn't wanting to fire off any kind of OnKeyDown event. I don't know why. Can anyone tell me what I'm doing wrong? <!DOCTYPE html> <html lang="en"> <head> <title>Canvas test</title> <meta charset="utf-8" /> <link href="/bms/style.css" rel="stylesheet" /> <style> body { text-align: center; background-color: #000000;} canvas{ background-color: #ffffff;} </style> <script type="text/javascript"> var x = 50; var y = 250; var speed = 5; function controls(event){ if(!e){ //for IE e = window.event; } if(e.keyCode==37){//keyCode 37 is left arrow x -= speed; } if(e.keyCode==39){ //keyCode 39 is right arrow x += speed; } if(e.keyCode==38){//keyCode 37 is up arrow y -= speed; } if(e.keyCode==40){ //keyCode 39 is down arrow y += speed; } } function update(){ document.onkeydown="controls(event);"; draw(); } function draw(){ var canvas = document.getElementById('screen1'); if (canvas.getContext){ var ctx = canvas.getContext('2d'); ctx.fillStyle = 'rgba(255,255,255,0.5)'; ctx.fillRect(0,0,500,500); ctx.fillStyle = 'rgb(236,138,68)'; ctx.fillRect(x,y,25,25); } } setInterval('update();', 1000/60); </script> </head> <body> <canvas id="screen1" width="500" height="500"></canvas> </body> </html>

    Read the article

  • Javascript self contained sandbox events and client side stack

    - by amnon
    I'm in the process of moving a JSF heavy web application to a REST and mainly JS module application . I've watched "scalable javascript application architecture" by Nicholas Zakas on yui theater (excellent video) and implemented much of the talk with good success but i have some questions : I found the lecture a little confusing in regards to the relationship between modules and sandboxes , on one had to my understanding modules should not be effected by something happening outside of their sandbox and this is why they publish events via the sandbox (and not via the core as they do access the core for hiding base libary) but each module in the application gets a new sandbox ? , shouldn't the sandbox limit events to the modoules using it ? or should events be published cross page ? e.g. : if i have two editable tables but i want to contain each one in a different sandbox and it's events effect only the modules inside that sandbox something like messabe box per table which is a different module/widget how can i do that with sandbox per module , ofcourse i can prefix the events with the moduleid but that creates coupling that i want to avoid ... and i don't want to package modules toghter as one module per combination as i already have 6-7 modules ? while i can hide the base library for small things like id selector etc.. i would still like to use the base library for module dependencies and resource loading and use something like yui loader or dojo.require so in fact i'm hiding the base library but the modules themself are defined and loaded by the base library ... seems a little strange to me libraries don't return simple js objects but usualy wrap them e.g. : u can do something like $$('.classname').each(.. which cleans the code alot , it makes no sense to wrap the base and then in the module create a dependency for the base library by executing .each but not using those features makes a lot of code written which can be left out ... and implemnting that functionality is very bug prone does anyonen have any experience with building a front side stack of this order ? how easy is it to change a base library and/or have modules from different libraries , using yui datatable but doing form validation with dojo ... ? some what of a combination of 2+4 if u choose to do something like i said and load dojo form validation widgets for inputs via yui loader would that mean dojocore is a module and the form module is dependant on it ? Thanks .

    Read the article

  • Why don't we just fix Javascript?

    - by Jan Meyer
    Javascript sucks because of a few fatalities well pointed out by Douglas Crockford. We talk a lot about it. But the point here is, why we don't fix it? Coffeescript of course does that and a lot more. But the question here is another: if we provide a webservice that can convert one version of Javascript to the next, and so on, we can keep the language up to date. Such a conversion allows old code to run, albeit with an ever-increasing startup delay, as newer browsers convert old code to the new syntax. To avoid that delay, the site only needs to take the output of the code-transform and paste it in! The effort has immediate benefits for those businesses interested in the results. The rest can sleep tight: their code will continue to run. If we provide backward code-transformation also, then elder browsers can also run ANY new code! Migration scripts should be created by those that make changes to a language. Today they don't, which is in itself a fundamental omission! It should be am obvious part of their job to provide them, as their job isn't really done without them. The onus of making it work should be on them. With this system Any site will be able to run in Any browser, but new code will run best on the newest browsers. This way we reap the benefit of an up-to-date and productive development environment, where today we suffer, supposedly because of yesterday. This is a misconception. We are all trapped in committee-thinking, and we drag along things that only worsen our performance over time! We cause an ever increasing complexity that is hard to underestimate. Javascript is easily fixed. The fact is we don't. As an example, I have seen Patrick Michaud tackle the migration problem in PmWiki. It included forward migration scripts. Whenever syntax changes were made, a migration script was added to transform pages to the new syntax. As far as I know, ALL migrations have worked flawlessly. In other words, we don't tackle the migration problem, we just drag it along. We are incompetent! And why is that? Because technically incompetent people feel they must decide for us. Because they are incompetent, fear rules them. They are obnoxiously conservative, and we suffer the consequence of bad leadership. But the competent don't need to play by the same rules. They can (and must) change them. They are the path forward. It is about time to leave the past behind, and pursue the leanest meanest, no, eternal functionality. That would in and of itself revolutionize programming. So, why don't we stop whining and fix programming? Begin with Javascript and change the world. Even if the browser doesn't hook into this system, coders could. So language updaters should take it upon them to provide migration scripts. Once they exist, browsers may take advantage of them.

    Read the article

  • Recieving and organizing results without server side script (JavaScript)

    - by Aaron
    I have been working on a very large form project for the past few days. I finally managed to get tables to work properly within a javascript file that opens a new display window. Now the issue at hand is that I can't seem to get CSS code to work within the javascript that I have created. Before everyone starts thinking "just use server side script idiot" I have a few conditions and info about the file: The file is only being ran local due to confidential information risks. Once again no option for server access. The intranet the computers are on are already top security and this wouldn't exactly be a company wide program The code below is obviously just a demo with a simple form... The real file has six pages of highly confidential information Only certain fields on this form will actually be gathered (example: address doesnt appear in the results) The display page will contain data compiled into tables for easier viewing I need to be able to create css commands to easily detect certain information if it applies and along with matching design of the original form Here is the code: <html> <head> <title>Form Example</title> <script LANGUAGE="JavaScript" type="text/javascript"> function display() { DispWin = window.open('','NewWin', 'toolbar=no,status=no,width=800,height=600') message = "<body>"; message += "<table border=1 width=100%>"; message += "<tr>"; message += "<th colspan=2 align=center><font face=stencil color=black><h1>Results</h1><h4>one</h4></font>"; message += "</th>"; message += "</tr>"; message += "<td width=50% align=left>"; message += "<ul><li><b><font face=calibri color=red>NAME:</font></b> " + document.form1.yourname.value + "</UL>" message += "</td>"; message += "<td width=50% align=left>"; message += "<li><b>PHONE: </b>" + document.form1.phone.value + "</ul>"; message += "</td>"; message += "</table>"; message += "<body>"; DispWin.document.write(message); DispWin.document.body.style.cssText = 'color:#blue;'; } </script> </head> <body> <h1>Form Example</h1> Enter the following information: <form name="form1"> <p><b>Name:</b> <input TYPE="TEXT" SIZE="20" NAME="yourname"> </p> <p><b>Address:</b> <input TYPE="TEXT" SIZE="30" NAME="address"> </p> <p><b>Phone: </b> <input TYPE="TEXT" SIZE="15" NAME="phone"> </p> <p><input TYPE="BUTTON" VALUE="Display" onClick="display();"></p> </form> </body> </html> >

    Read the article

  • OOP Design for an Economy

    - by waiwai933
    Not sure where to start, so I'm just going to plow in. Let's say I'm trying to represent an economy in OOP. A basic design I've come up with is: class Person{ int $money; // Money someone has in wallet/purse int $bank_account_id; function getAmountOfMoney() function addMoney($amountToAdd) function subtractMoney($amountToSubtract) } class BankAccount{ int $money; // Money in Bank Account int $interest_per_year; function giveInterest() function depositMoney() // Calls $person->subtractMoney() function withdrawMoney() // Calls $person->addMoney() } Are there any design flaws here?

    Read the article

  • how to implement OOP using QT

    - by kaycee
    hi, this is a simple OOP QT question. my app consists of main window (QMainWindow) and a table (QTableWidget). in the main window i have arguments and variables which i would like to pass to the table class, and to access methods in main widnow class from the table class, how should i do it ? mainwindow.h class MainWindow : public QMainWindow { Q_OBJECT private: int a; int b; Spreadsheet *spreadsheet; public: void set_a(int); void set_b(int); spreadsheet.h class Spreadsheet : public QTableWidget { Q_OBJECT public: Spreadsheet(QWidget *parent = 0); atm i define Spreadsheet like this: spreadsheet = new Spreadsheet(this); and i'd like to access set_a() from spreadsheet.cpp...

    Read the article

  • PHP: OOP and methods

    - by Pirkka
    Hello I`ve been wondering how to implement methods in a class. Could someone explain me what means if one does OOP in procedural style? Here is an example: class Fld extends Model { private $file; private $properties = array(); public function init($file) { $this->file = $file; $this->parseFile(); } private function parseFile() { // parses the file foreach($this->file as $line)...... .................. $this->properties = $result; } } I mean is it a good thing to have methods like these that do operations for the class properties like that. Or should I pass the class property as method parameter... I mean this would cause error if the file property wouldnt be declared.

    Read the article

  • Why people do not like OOP? [closed]

    - by Gabriel Šcerbák
    I do not understand why people choose C++ over Smalltalk in past and why Java over Python or Ruby. What is it that ties people so much to the procedural programming and makes it so difficult to go "all the way" to object oriented programming? What makes OOP hard? Should not objects be an abstraction which is easier to grasp for people, i.e. a more natural one than procedures? Is education the problem (because people tend to learn procedural programming before object oriented)?

    Read the article

  • Searching for a complex and well-designed PHP OOP application to learn from

    - by Raveren
    Basically, I am diving ever deeper into complex programming practices. I've almost no friends that are experienced (or more experienced than me) programmers to learn from, so I am looking for the next best thing - learning from the work of strangers. Can anyone recommend a real world finished and working application written well and OOP-centered. I'd like to take and analyze its source. Bonus if it's based on Zend Framework. What I am interested most in is objects that unlike desktop applications, have only one real operation done to them (or to their representation in DB or session) during their lifetime (or pageload), like user-logIn(). I'm interested in optimal and reusable design patterns and their real life implementations.

    Read the article

  • Python: confused with classes, attributes and methods in OOP

    - by user1586038
    A. Am learning Python OOP now and confused with somethings in the code below. Question: 1. def init(self, radius=1): What does the argument/attribute "radius = 1" mean exactly? Why isn't it just called "radius"? The method area() has no argument/attribute "radius". Where does it get its "radius" from in the code? How does it know that the radius is 5? """ class Circle: pi = 3.141592 def __init__(self, radius=1): self.radius = radius def area(self): return self.radius * self.radius * Circle.pi def setRadius(self, radius): self.radius = radius def getRadius(self): return self.radius c = Circle() c.setRadius(5) """ B. Question: In the code below, why is the attribute/argument "name" missing in the brackets? Why was is not written like this: def init(self, name) and def getName(self, name)? """ class Methods: def init(self): self.name = 'Methods' def getName(self): return self.name """

    Read the article

  • Connecting data to a GUI - OOP

    - by tau
    I have an application with several graphs and tables on it. I worked fast and just made classes like Graph and Table that each contained a request object (pseudo-code): class Graph { private request; public function setDateRange(dateRange) { request.setDateRange(dateRange); } public function refresh() { request.getData(function() { //refresh the display }); } } Upon a GUI event (say, someone changes the date range dropdown), I'd just call the setters on the Graph instance and then refresh it. Well, when I added other GUI elements like tables and whatnot, they all basically had similar methods (setDateRange and other things common to the request). What are some more elegant OOP ways of doing this? The application is very simple and I don't want to over-architect it, but I also don't want to have a bunch of classes with basically the same methods that are just routing to a request object. I also don't want to set up each GUI class as inheriting from the request class, but I'm open to any ideas really.

    Read the article

  • Inheriting database connection in PHP OOP

    - by vrode
    My abstract class Database is made for database interaction and any child of this class (UserDatabase, ActionDatabase, EventDatabase) inherits its database connection which is defined as static. `abstract class Database { static $connection = mysql_connect( ); } class UserDatabase extends Database { ... public function __construct( ) { $connection ? "connected" : "not connected"; $this-table = "users"; mysql_query( "FROM " . $this-table . " SELECT *" ); } } ` Does that mean, that my database connection is only set up and stored in memory once and passed on to subclasses as reference without being replicated for each instance? Is this how you would implement you OOP-correct database interface?

    Read the article

  • OOP PHP simple question

    - by Tristan
    Hello, I'm new to OOP in PHP, is that to seems correct ? class whatever { Function Maths() { $this->sql->query($requete); $i = 0; while($val = mysql_fetch_array($this)) { $tab[i][average] = $val['average']; $tab[i][randomData] = $val['sum']; $i=$i+1; } return $tab; } I want to access the data contained in the array $foo = new whatever(); $foo->Maths(); for ($i, $i <= endOfTheArray; i++) { echo Maths->tab[i][average]; echo Maths->tab[i][randomData]; } Thank you ;)

    Read the article

  • Many-to-many relationship in oop

    - by Manu
    what is best way to model many-to-many relationship? lets say we have a two classes , Team and Player any given Player can be in multiple Team s any Team can have as many Player s as they like I like to call methods like playerX.getTeamList() to get the list of all the Team s he/she is in teamY.getPlayerList() to get the list of all the Player s in the team (or have some other way to do this effectively) I can think of two ways of doing this , but they just don't feels like good oop pattens. can you think of any good ways , perhaps a design patten ?

    Read the article

  • Using Classes / OOP in PHP

    - by Alex Demchak
    I'm pretty proficient with PHP, outside of OOP - which I am just now starting to jump in to. I've been watching videos and reading tutorials, but they are all still pretty confusing... If I have FILE 1 (class.time.php) class Time { function GetTime(){ $time = date('H:i:s'); printf($time); } } and then in a nother php page I've got FILE 2 (page.php) I can do include('class.time.php'); and then anywhere in this page I can then do $time = new Time; //Calling the class and setting the class to a variable $time->GetTime(); //This is BASICALLY saying (run the 'GetTime' function in the 'Time Class' My main question is, is the comment above (This is BASICALLY saying.....) correct? or is there a better way to think of it?

    Read the article

  • PHP oop build array

    - by Industrial
    Hi! If I would need to build up an array with OOP based PHP, would this be the proper way to do it? class MyClass { $array = array(); function addElement($value) { $this->array[] = $value; } function fetch() { $return = $this->memcached->getMulti($this->array); return $return; } } PHP file where it will be used: <?php $this->myClass->addElement('key1'); $this->myClass->addElement('key1'); $this->myClass->addElement('key1'); $var = $this->myClass->fetch(); Thanks a lot

    Read the article

  • How to access function inside PHP OOP

    - by Industrial
    Hi everyone, What do I need to do to call $this-two() from inside my function innerOne? Is that possible with PHP OOP? Here's the error I am recieving: Fatal error: Using $this when not in object context Here's how my code looks: class myClass { function one(){ function innerOne() { // Some code $this->two($var1, $var2); } // Some code innerOne(); } function two($var1, $var2) { // Does magic with passed variables return $var1 . $var2; } } Thanks a lot!

    Read the article

  • Inventory Management OOP design

    - by rgamber
    This was an OOP design and implementation interview question, which I came across on glassdoor.com. Design and implement a inventory management system to minimize the number of missed delivery dates while keeping costs to the company low. Of course there is no right answer to this, but I am not sure I understand the question correctly and am wondering what would be a good answer. Is this as simple as creating an undirected graph with nodes as the delivery points, and edges having weights as the cost of the delivery, and then use a single-source-shortest-path algorithm (like Dijkstras, or Bellman-Ford) on the graph? Not sure if this type of question should be asked here,so let me know and I will delete it.

    Read the article

  • game inventory/bag system javascript html5 game

    - by Tom Burman
    im building an RPG game using html5's canvas and javascript. Its tile based and im using an array to created my game map. I would like the player to have a bag/inventory so when they select or land on a tile that has an item on it, they can click on it and store it in their bag/inventory. I was thinking of using a 2d array to store the value of the item tile, a bit like my map is doing, so when the player lands on, lets say a rope tile which is tileID 4, the value 4 is pushed into the next array position available, then reloop through the array and reprint it to the screen. For an example of what im trying to achieve visually, would be like runescapes inventory, but dumbed down a bit. I appreciate any views and answers. Im not great at javascript coding so please be patient Thanks Tom

    Read the article

  • Visual Studio 2008 “Format Document/Selection” command and a function named “assert” in JavaScript c

    - by AGS777
    Just have found some funny behavior of the Visual Studio 2008 editor.  Sorry if it is already well known bug. If you happened to have a JavaScript function named “assert” in your code (and there is pretty high likelihood in my opinion), for example something like: function assert(x, message) { if (x) console.log(message); } then when either Format Document (Ctrl + K, Ctrl + D) or Format Selection (Ctrl + K, Ctrl + F) command is applied to the document/block containing the function, the result of the formatting will be: functionassert(x, message) { if (x) console.log(message); } That’s it. function and assert are now joined into one solid word. So be aware of the fact in case you suddenly start receiving  strange exception in your JavaScript code: missing ; before statement functionassert(x, message) And no, it is not an April Fool's joke. Just try for yourself.

    Read the article

  • Pure Front end JavaScript with Web API versus MVC views with ajax

    - by eyeballpaul
    This was more a discussion for what peoples thoughts are these days on how to split a web application. I am used to creating an MVC application with all its views and controllers. I would normally create a full view and pass this back to the browser on a full page request, unless there were specific areas that I did not want to populate straight away and would then use DOM page load events to call the server to load other areas using AJAX. Also, when it came to partial page refreshing, I would call an MVC action method which would return the HTML fragment which I could then use to populate parts of the page. This would be for areas that I did not want to slow down initial page load, or areas that fitted better with AJAX calls. One example would be for table paging. If you want to move on to the next page, I would prefer it if an AJAX call got that info rather than using a full page refresh. But the AJAX call would still return an HTML fragment. My question is. Are my thoughts on this archaic because I come from a .net background rather than a pure front end background? An intelligent front end developer that I work with, prefers to do more or less nothing in the MVC views, and would rather do everything on the front end. Right down to web API calls populating the page. So that rather than calling an MVC action method, which returns HTML, he would prefer to return a standard object and use javascript to create all the elements of the page. The front end developer way means that any benefits that I normally get with MVC model validation, including client side validation, would be gone. It also means that any benefits that I get with creating the views, with strongly typed html templates etc would be gone. I believe this would mean I would need to write the same validation for front end and back end validation. The javascript would also need to have lots of methods for creating all the different parts of the DOM. For example, when adding a new row to a table, I would normally use the MVC partial view for creating the row, and then return this as part of the AJAX call, which then gets injected into the table. By using a pure front end way, the javascript would would take in an object (for, say, a product) for the row from the api call, and then create a row from that object. Creating each individual part of the table row. The website in question will have lots of different areas, from administration, forms, product searching etc. A website that I don't think requires to be architected in a single page application way. What are everyone's thoughts on this? I am interested to hear from front end devs and back end devs.

    Read the article

  • Is traditional JavaScript image pre-loading taboo

    - by Evan Plaice
    I remember the good-old-days (not really) back when I was still sucking the teet of Dreamweaver to build websites and the lure of playing copypasta with fancy built-in scripts (ex, image-swap) was like black magic. I'm pretty far removed from that now days but I was adapting a small site from it's original FrontPage (::cringe::) format to a standard HTML/CSS implementation and couldn't help wondering... should I should re-implement the JavaScript image pre-loading into the current version? Or, is there a better way? I don't want to block the page from loading by requiring the user to request all the assets withing the page by using the traditional JavaScript pre-loader method. I value giving the user something to look at ASAP, and there's some potential harm to my Google mojo by doing so. Is there a cleaner solution to prevent unnecessary page-reflows during loading? Such as, setting the static width/height dimensions through a CSS style attribute on the image element.

    Read the article

  • Lua & Javascript documentation generation

    - by Tiddo
    I am in the beginning phase of create a mobile MMO with my team. The server software will be written in JavaScript using NodeJS, and the client software in Lua using Corona. We need a tool to auto-generate documentation for both the server-side and client-side code. Are there any tools which can generate documentation for both Lua and Javascript? And as a bonus: we are hosting our project on Bitbucket and the Bitbucket Wiki uses the Creole markup language. So if it's possible I want the tool to export to Creole.

    Read the article

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