javascript

Performing an action on Parent/Child elements independently.

I have HTML similar to the following in my page <div id="someDiv"> <img src="foo.gif" class="someImg" /> </div> The wrapper div is set up such that when it is clicked, it's background-color changes using the following jQuery code. $("div").click(function(event){ $(this).css("background-color", "blue"); }); I also have some ...

How to change source order of <div> in less steps/automatically?

How can I do this task automatically. I need to change source order of the divs, which has same id in above 100 pages. I created an example: This is default condition <div class="identification"> <div class="number">Number 1</div> </div> <div class="identification"> <div class="number">Number 2</div> </div> <div class="identificat...

Find word using JQuery

I need a little piece of advice. I have a test page with 2 fields: word number and URL Also i have a button Push. When i push the button i want to open the specified URL (it's local html files) and highlight the word at the "word number" position Of course the code must ignore element nodes (<p>,<b>,<table> and so on) ...

javascript (greasemonkey) how to access a newly created iframe

hi there, i have this website, by clicking on certain link on the website an iframe will be created within the same window. my question, just wondering how to access this iframe? i tried document.getElementById() return null tried window.frames not there Thanks ...

jQuery Swap Image on Click and if/else

Im stuck, Im setting a variable when someone clicks, then testing with if to see if the variable exists and doing something else. Its a simple script which Im probably overthinking, would love someone's thoughts. $('.view-alternatives-btn').live('click', function() { //$("#nc-alternate-wines").scrollTo(); //$('.nc-remove').toggl...

How to match !x but not !!x in JS regex?

Given the following text: This is!!xa simple string!xpattern I would like to get a regexp that matches the !x that's between "string" and "pattern" but not !!xa that's between "is" and "a". This regexp is to be used inside a string split(). I have tried several combinations but I cannot get a regexp that meets my needs. Perhaps my ex...

Fixing CSS positioning and scaling

I was contemplating writing a UI toolkit where setting the position and size of an element/widget was intuitive and powerful. Here are some examples of how it would be used (not currently implemented): ui("Panel").size(". 40").pos("0 0").attach(element); ui("Textarea").size(". %-10").pos("0 40").attach(element); ui("Panel").size(". 10")...

window.location alternatives in JavaScript

What is a standardized alternative to window.location.href property? I was checking on w3schools.com that it is implemented in all major browsers so there's no problem but I'm rather curious how to do that properly. From here is the statement that the function is not standardized: https://developer.mozilla.org/en/DOM/window.location ...

jQuery Dialog form serialize reposting incorrect data on subsequent uses

I'm working with forms inside jQuery Dialog, and am having some issues with the data it's posting. First load and save works fine, posts the correct data. Until I refresh the page though, every subsequent load seems to work, as in the correct data is in the form, however, when saved, the data from the first load is what is posted every t...

How to loop a key/value object in javascript

var user = {}; now I want to create a setUsers method that takes a key/value pair object and initializes the user variable. setUsers = function(data) { // loop and init user } where data is like: 234: "john", 23421: "smith", .... ...

Want to create a multilingual javascript object, how to handle if lots of labels?

I want to create a javascript file for multilingual functionality i.e. display the error message in the correct language. If I have allot of labels for a page, error messages, etc., what is a smart way of making this so the actual output on the page isn't huge? i guess the best way is to somehow output the labels that I need ONLY? la...

Grails: JavaScript integration

I have grails server on http://mysite.com:8086/project/ ApiController renders some text(html code in my case) http://mysite.com:8086/project/api/lastorders I have another server http://othersite.net/ - this is simple apache server with HTML page. I want to show text returned from server on my page. I've tried: <script type="text...

How to rewrite the Jquery dynamic selection box script for 5 selection boxes?

Hi, I am trying to create dynamic selection boxes with Jquery. Due to requirements, I have 5 selection boxes with similar Class contents e.g. Class A, Class B, Class C, etc. I have another 5 Student selection boxes besides each of the Class selection boxes. So the idea is that when I select a class selection box, javascript will chec...

How to get the domain value for a cookie in Javascript?

Using Javascript I'd like to get the domain value for a specific cookie. Is this possible? If so, how? To clarify: I'm not looking for the value of the cookie. I'm on "subdomain.domain.com" and I need to remove a cookie whose name is known but its domain value is something like ".domain.com". In short: I'd like to get the value of ".do...

Having trouble parsing XML with jQuery

Hi Guys, I'm trying to parse some XML data using jQuery, and as it stands I have extracted the 'ID' attribute of the required nodes and stored them in an array, and now I want to run a loop for each array member and eventually grab more attributes from the notes specific to each ID. The problem currently is that once I get to the 'for'...

jQuery get value from checked element with a given name

I've got an input like so: I'd like to use jQuery to grab that element, and add the function call foo() to the change event. Currently I can get it done, but there are two hacks involved. My (working) code: $(":input[name*=myfield]").change( function( $(":input[name*=myfield]") ) { foo(); }); )}; There are two hacks in there ...

How to submit a form via AJAX using a different action?

I have a form element and that has a normal submit button but I also want to be able to submit an AJAX get request using the values entered in the form but make it to a different address (this is independed of the submit button). Is there an easy way to do that? The long version: I have a form with several select elements in it and ...

Virtual Includes not recognized

I am attempting to include a header in my html file. <!--#include virtual="/header.shtml" --> This is not being read by the browser. The file works fine when I go to it alone. It works fine when I had it in the header (not through an include file). Do some servers not allow this kind of include? ...

JQuery each loop problem

Hello, I have the following code <div> <a href="#" class="clickMe">test</a> <ul> <li class="action_li">1</li> <li class="action_li">2</li> </ul></div> <div> <a href="#" class="clickMe">test</a> <ul> <li class="action_li">3</li> <li class="action_li">4</li> </ul> and I want to loop on all the <li> that ar...

Multiple TinyMCE editors, but only one toolbar?

Hello there. I've looked around the forum, but cannot seem to find a definite answer to this problem... I'm using jQuery and TinyMCE on our website. I've gone through the docs of TinyMCE, but am still getting lost I'm afraid. We're doing an interface that requires edit-in-place in multiple places in the page. The only thing is, each of ...