javascript

Perform function on form submit

Hopefully this is a pretty simple question! I've got the code working in jQuery to listen for a specific form on a page to be submitted and perform an alert when it is.. I.e.: The form itself doesn't have an ID so I am targeting the form within a specific DIV ID. $("#content form").submit(function() { alert("lorem ipsum dolor?");...

How do you make the tab that is selected the default tab for idtabs

I am using the idtabs script from http://www.sunsean.com/idTabs/ and so far they work awesome. However, I am looking for a way to make it so that when the page reloads, the same tab that was selected is still open. So far i'm thinking there must be a way to set the .selected class to assign the default tab. I'm a huge js rookie so any id...

Number test in loop

I was looking to create a boolean test for a number when it is 10, 20, 30, 40. This would be used in a loop, 1 to 100. ParseInt seems a bit part but was wondering what a method for a true or false answer maybe. ...

call function from external js (php) file

Hi, I have a file where I keep all scripts so my pages wouldn't get messy (I have php file which generates required javascript). My includes basically look like this: <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="script.php"></script> </head> <body> <input type="bu...

How to import php with javascript?

I know JavaScript is client side and PHP is server-side. I also know this is an odd question. However, the CMS editor I'm using will not allow php to be stored to the database (it's the same editor used by Dupral). I can store JavaScript though. Can I import a php file with JavaScript. Or rather read the php file, store the content in a...

JavaScript Split without losing character

I want to split certain text using JavaScript. The text looks like: 9:30 pm The user did action A. 10:30 pm Welcome, user John Doe. 11:30 am Messaged user John Doe Now, I want to split the string into events. i.e.: 9:30 pm The user did action A. would be one event. I'm using RegEx for this: var split = journals.split(/\d*\d:/); ...

Parsing complex string using regex

My regex skills are not very good and recently a new data element has thrown my parser into a loop Take the following string "+USER=Bob Smith-GROUP=Admin+FUNCTION=Read/FUNCTION=Write" Previously I had the following for my regex : [+\\-/] Which would turn the result into USER=Bob Smith GROUP=Admin FUNCTION=Read FUNCTION=Write FUNCT...

jQuery Plugin with $.getJSON Returning undefined?

Inside of a jQuery plugin I made I have: $.getJSON(base_url,{ agenda_id:defaults.id, action:defaults.action+defaults.type, output:defaults.output },function(json){ return json; }); And in a separate JS file (yes, it comes after the plugin): json = $('#agenda-live-preview').agenda({action:'get',type:'agenda',output:'js...

Best way to sign data in web form with user certificate

We have a C# web app where users will connect using a digital certificate stored in their browsers. From the examples that we have seen, verifying their identity will be easy once we enable SSL, as we can access the fields in the certificate, using Request.ClientCertificate, to check the user's name. We have also been requested, howev...

innerHTML doesn't work correctly with xhtml in Chrome

Hi! I've got a trouble with Chrome5.0.375.70, but FF 3.6.3 and Opera 10.53 are OK. Below is the line of code: document.getElementById('content').innerHTML = data.documentElement.innerHTML; The data object from the code is a document (typeof(data) == 'object') and I've got it by ajax request to chapter01.xhtml: <?xml version="1.0" e...

Selecting all elements

This should be really simple but I'm a javascript/jQuery rookie, so here we go: With the following code I can select a certain element var user = $(".ui-selected .user-name").html(); But if there are multiple elements with the above classes, only the first value gets selected. What I would like to accomplish is a variable with all th...

Why does the assignment operator return a value and not a reference?

I saw the example below explained on this site and thought both answers would be 20 and not the 10 that is returned. He wrote that both the comma and assignment returns a value, not a reference. I don't quite understand what that means. I understand it in relation to passing variables into functions or methods i.e primitive types are p...

Javascript split with RegEx

Hey again, I just asked a question about Regex, and received a great answer: http://stackoverflow.com/questions/3047201/javascript-split-without-losing-character Now, I have another question. My current Regex looks like this: var split = text.split(/(?=\w*\d*\d:\d\d)/); Basically, I'm trying to split using the timestamps (eg - 9:3...

How do I display a sting, based on which id is set as selected?

I'd like to display a text string (to be positioned above ul) depending on which link is set to selected by the chgClass fuction. The ids for each display via an alert right now, but I can't seem to make them appear in "english". I know I can set up an array stating "id=text string" but when I do it seems to break the code I already have...

click a button automatically using greasemonkey

Hi all, There is a button in the web page as <input class="button" type="submit" value="new"> I need a greasemonkey script which even before the page completely loads must automatically click on the button and move to next page. Thanks. ...

get $_SERVER['HTTP_X_REQUESTED_WITH'] with iframe

I'm working with Colorbox and if I specify to use an iframe with it then the $_SERVER['HTTP_X_REQUESTED_WITH'] variable is no longer available to me. I need that in order to detect if ajax has loaded so then I can include a header/footer or not. Anyway to get this variable or is there another variable that I can get when I use iframe? ...

I am trying to make a simple toggle button in javascript.

I am trying to make a simple toggle button in javascript. However, the button will only turn "OFF" and will not turn back "ON" <html><head></head> <script type="text/javascript"> function toggle(button) { if(document.getElementById("1").value=="OFF"){ document.getElementById("1").value="ON";} if(document.getElementById("1").valu...

I want to get the latitude and longitude from the Gmap control into textboxes

Hi All. I tried with the following but it doesn't work var txtlat=document.getElementById('TextBox1').value=GMap1.getCenter().lat(); var txtlong=document.getElementById('TextBox2').value=GMap1.getCenter().lng(); It gives a JavaScript error as "Object doesn't support this property or method". How can i do this???? I really need help...

How to use JS to simulated a event of click a link on chrome?

How to use JS to simulated a event of click a link on chrome? I want the effect of autoclick. ...

Passing javascript form variables into jQuery function not working

I am trying to pass some JavaScript variables that I have assigned to form variables into a query string used by a jQuery plug in called fancybox. If I hard code in the string that I want lightbox works great, however I need it to pass some form values in there to make it work as desire. <script type="text/javascript"> $(document)....