javascript

Codeigniter: How to include javascript files

Hello I just started working with CodeIgniter framework. My current directory structure is Demo(Project name) +System +Spplication -Controllers -demo.php +Model +Views -view_demo.php +Js -ajax.js -jquery.js Please tell me how to include .js files in view_demo.php. Thanks Raj ...

Submit Event Listener for a form

I've written an event listener for a form submit that is causing me a few issues. When pressing 'enter' inside the text field everything works fine. However, I have an span (with background-image) that submits the form as well via a click event. This is not working properly and I can't figure out why. Here's the basic HTML: <form name...

Do browsers ignore window parameters when opening new windows via javascript?

I'm opening a popup window via javascript. I'm trying to set some of the display parameters - specifically we want to hide the location and statusbar, but every browser I've tested this in, the location and status bars still display. My code looks like this: newwindow=window.open(url,'name','height=250,width=290,left=200,top=200,locati...

Using JavaScript, how can I reset all the select's in my form so that the first option for each is selected?

Hi, I have a form containing only select fields, a submit button and a reset button. <form id="search_form"> <select id="country"> <option value="-1">Select Country</option> <option value="22">USA</option> <option value="23">Germany</option> ... </select> <select id="regions"> <option value="-1">Select Region</option> .....

Calling a callback in javascript

I am not so strong in javascript. I have a common function that I call from many parts of my code passing them some parameters. Can somebody help me on how to define a new parameter for this function that should be a callback with no parameters passed from the caller (like many jquery plugins do) how to handle the callback call ins...

Is there a way to force the user to download a file from a href link rather than to open it in a browser window?

Basically I wrote a script that generates a xml file based on user input. After the file is generated a download link appears like so: <a href="path/to/file.xml">Download File</a> But when clicked it opens the xml in the browser, I want it to start downloading when the link it clicked instead. Is there any way to achieve that? ...

Javascript widget implementation

I have a question about Javascript widgets. The widget I am working on simply embeds content on a page instead of using iframes. So far it looks good. But there are cases where some users layouts are messing up the widget. For example, the widget might require a width of 300px to appear. But the parent div is set to 250px and hence ...

Is there a way to attach a Javascript object to a Select Option

When building up a list of options in a select list using Javascript I'd like to attach a Javascript object to that option that I could easily retrieve in the change event. So, while writing this question I wanted to provide some sample code and found a way to make this work; so I have a slight addition to the question. Is it bad to att...

How do I detect if the browser window is active

The code im currently using is this var focus; function focuswindow() { focus = true; } function hidewindow() { focus = false; } window.onfocus = focuswindow(); window.onblur = hidewindow(); The idea is that it can be used like this if( focus ) { //do something } However its not working. Also it only needs to work on Chrome (so no ...

How can I load the attributes of a CSS class in a stylesheet directly into a hash using JavaScript or jQuery?

I want to load the key value pairs from a class, or id, in a CSS stylesheet into a JavaScript object in order to access the data. Note that I do NOT want to add that class to a DOM element (at least not directly) The only way I can see in JQuery is to create a dummy hidden element, add my class to it using $(“#dummy").addClass(“myclas...

Set input values according to children of the parent div

given series of DIVs w/unique ID as in: <div id="2988"> <div class="site">YaHoot.com</div> <div class="logo">/images/yahootLogo.jpg</div> //[and so on] <input type="button" value="YaHoot" onclick="javascript:processMe('2988');" /> </div> //[followed by bunches more divs repeating that structure] I'm trying to code a clic...

Find element by style selector in jquery

Hello everyone, I am trying to find an element with a particular style and change its style to something else. Here is the html element <table style='width: 555px;'> <tr> <td>blablabla</td> </tr> </table> Now I am trying to find the table with width 555px and change it to 650px using jquery. $('table[style*=width:555px]').c...

What are good JS libraries for game dev? (HTML5)

If i decide to write a simple game both text and graphical (2d) what libs may i use? Assuming we are using a HTML5 compatible browser. The main things i can think of Rendering text on screen Animating sprites (using images/css) Input (capturing the arrow keys and getting relative mouse positions) Perhaps some preloading resource or dy...

Javascript mysql interface?

I am going back though a web-based document numbering system from few weeks ago. To sum it up, the user types in the project,class,base, and dash number (PPP-CCC-BBBB-DDD) then it is added to a mysql database. Now most doc numbers go in order according to revisions. IE: A document 1465-630-0001-000 becomes, after revision, 1465-630-0002-...

Need help refactoring this Javascript if/else statement

Here's my current if/else statement: var current_class = $(this).closest("article").attr("class") if (current_class == 'opened') { $(this).closest("article").removeClass('opened'); $(this).closest("article").addClass('closed'); } else { $(this).closest("article").removeClass('closed'); $(this).closest("article").addClass('opene...

Javascript keycodes

Hi Folks, I am facing is weird problem. I have an input field on my page which gets its feed from a barcode scanner which appends a carriage return at the end (keycode: 13). When I use my scanner on a regular notepad, Once the input prints on screen, the cursor moves to the next line (it gets the carriage return), where as if I ...

Grouping list items (LIs) to OLs/ULs using jQuery

Is it possible, using Javascript and either jQuery or regular expressions, to group multiple sibling list items in HTML as in the example below? I need to convert TikiWiki markup to HTML, and it uses ungrouped lists (just adjacent lines appended with #). <li>Item 1.1</li> <li>Item 1.2</li> <li>Item 1.3</li> <p>Paragraph</p> <li>Item 2.1...

Iterating through specific radio groups only, within a larger set of radio groups

I have a form with 26 questions, all of which have radio button groups as an answer choice for the user (it calculates the risk factor for a specific invasive plant species on a given property). At the end, the selected value within each radio group is added up. What makes it complicated is that the user has the option of filling in th...

jquery plugin extend defaults problem

Hi everyone this is my first post so I hope I am posting to the right place. I am trying to develop a dialog/modal plugin. this is my first plugin and I'm not sure if I have produced it in the correct way. The problem I am having is that the $.extend is not updating the settings object. I've got 2 elements using the plugin. the #dialog...

How to load data on a text field?

I have two text fields and whenever I write a number in the first one, it should give me its name on the second field. Let's say I write 11 on the "first" field, then it should automatically put the word 'eleven' (NOT number itself) on the "second" field. And the same thing with any number. I know this can be done with jQuery but I jus...