javascript

Turn jQuery into vanilla JS - Insert p element after h1

Any ideas on how I would convert this jQuery to vanilla JS: $('.section > h1').after('<p>This paragraph was inserted with jQuery</p>'); I am new to jQuery and even newer to vanilla JS. This is as far as I got: var newP = document.createElement('p'); var pTxt = document.createTextNode('This paragraph was inserted with JavaScript'); ...

Variable not being updated on button click?

Hi everyone, I'm making a simple jQuery script that will allow you to change something on the click of a button. My problem is that if I change the value (checked), and then click the submit button, it will recognize it as the default. If you do this on the default, it is set to off, so if you check it off (turn on) and then click the su...

If I use "FindControl" outside a UserControl, what do I use within a UserControl?

Suppose I have javascript within ASP.NET UserControl: function setValue(DataItem) { var selectedDate = DataItem.getMember('DomainNameKey').get_object(); Picker1.setSelectedDate(selectedDate); } Where Picker1 is also inside the control. Because Picker1's ID will be renamed at runtime, what do I put in the code below to make ...

jQuery: get the type of an Ajax response

I need to make an Ajax request, but its response may vary and it's decided on the server side. Is there any way to know what type the response is? It may look similar to: $.post(url, pars, function (response, type) { if (type=='json') ... if (type=='html') ... }); Thanks ...

How can I highlight every single word in jquery so that I can provide a definition for each word?

What I am trying to do is allow the user to scroll over any word on a web page and when the mouse goes over the word it is highlighted (I know I can use hover for that). However I do not know how to select individual words, from the paragraph. The ultimate goal is to allow the user to click on the word and a definition appears over the...

Embed Telnet Control in Webpage

I was wondering if there are any Telnet "controls" that can be embedded into a web page (more specifically, a ASP.NET MVC page). I'd prefer not to use an ActiveX control, but I am open to any suggestions (a Javascript solution would be ideal). ...

"Smart" text area auto indent

I'm attempting to make an auto-indenting textarea and so far it works with the following code. The problem that I'm having is that I'm currently preventing the default action of pressing enter in order to calculate the tabs in the line, and then inserting the newline afterwards. This works, but I want to have the default action of the t...

clearTimeout on Mouseover Event not clearing setTimeout from Mouseout Event

I have some code that adds mouseover events and mouseout events to all 'a' tags on a page. I'd like it so that the mouseout starts a 5 second timer after which time it calls a function. However, if a new mouseover event fires, it should cancel any existing timers. The code I'm using follows. The setTimeout() is working fine, but it se...

Wait 3 seconds before form submits | JavaScript

I have this piece of code here: function checkAmount() { var PayField = document.getElementById('paymentamount'); var Pound = document.getElementById('pound'); if (PayField.value == "") { PayField.style.border = '1px #F00 solid'; Pound.style.color = '#F00'; alert('You need to enter an amount that...

<input type="button" runat="server" /> won't work in ASP.NET

Okay, this may seem silly, but on an ASP.NET .ascx control, I'm trying to use: <input type="button" runat="server" /> instead of: <asp:Button runat="server" /> And it's not working for me. This code: <asp:Button id="btnBuyCat" runat="server" Text="Buy Cat" ToolTip="Click to buy a cat" OnClick="btnBuyCat_Click" EnableViewState="fa...

How do I create a Single Select checkbox list using Ext.ListView component?

Hi all, I'm trying to create a checkbox list using ListView component. Below is my code. <script type="text/javascript"> Ext.onReady(function(){ Ext.BLANK_IMAGE_URL = 'blank.gif'; var genres = new Ext.data.SimpleStore({ fields: ['id','genre'], data: [['1','Comedy'],['4','Drama'],['3','Action']] }); var list1 = new Ext.li...

jQuery CSS 'or' selector

Hello, I am trying to select elements of a (certain class || another class) with the same selector. How can I go about doing that? Currently, I have: $(".class1 .class2").each(function(idx, el) {... }); however, that only selects elements that match both classes, not one or the other. How can I select elements that match one or bot...

Best way to obfuscate an email address

I'm creating an application that requires passing email addresses around in querystrings and linking to these pages in public documents. I'd like to prevent my site from becoming spambot heaven, so I'm looking for a simple algorithm (preferably in JavaScript) to encrypt/obfuscate the address so it can be used publicly ina URL without m...

Javascript Callback Function

Here's the problem, I'm trying to do an automatic test to see if addToCart() works correctly. addToCart(); if(Kiosk.GetCart().toString() !== emptyCartString){ setTestResults('addToCart', 'Passed'); } else{ setTestResults('addToCart', 'Failed'); } I'm adding a product to an empty cart, then I want to check to see if the cart is...

Is it possible to get jquery objects from an html string thats not in the DOM?

For example in javascript code running on the page we have something like: var data = '<html>\n <body>\n I want this text ...\n </body>\n</html>'; I'd like to use and at least know if its possible to get the text in the body of that html string without throwing the whole html string into the DOM and selecting from there. ...

Print multiple documents continuously

Hi, I want to implement a continious printing of document.Please see image below When I choose the checkboxes then click the print button, all the information of a particular applicant will be printed.Take note that each document was printed on a new page. I found a soluton from this forum http://bytes.com/topic/asp-net/answers/861073-...

What does this (useless?) javascript code do?

While debugging a javascript code that uses jQuery I found the following code: [0, 0].sort(function() { baseHasDuplicate = false; return 0; }); By my understanding of javascript this code will sort array containing two zeroes with comparison function that will always set a global variable and will return equality, which has sa...

get value of a list

Hi, <select name="my_field" onChange="my_field_change();"> <option value="1" <% nvram_match("my_field", "1", "selected"); %>>Enabled</option> <option value="0" <% nvram_match("my_field", "0", "selected"); %>>Disabled</option> </select> ... function my_field_change() { var my_value = document.forms[0].my_field.value; ... ...

Are alert()'s the Javascript equivalent of Visual Studio IDE breakpoints?

I'm trying to find a less haphazard way than a write-and-test way to write Javascript. I don't really use an IDE - I write, then test in browser - if anything's wrong, I then use alert()'s to try tracing. This can be a tedious process having to go back and forth from Notepad++ to the browser, so I wonder if there are better ways of doing...

Simple XOR a message (Javascript/Tcl)?

I need the username/password to be scrambled at the client-side before sending it over via HTTP GET/POST. And the server will decode it with Tcl, before the checks against database. Currently I'm thinking about using JavaScript for the client-side. Java Applet will also do. Is there any way, that I can easily achieve it, using Simple X...