javascript

how did you put the magnifying glass and "search" in the search box in stackoverflow?

Assuming it is possible with just CSS...but wanted to know if someone could share the code. Guessing magnifying glass is background image, but need javascript to remove "search" on focus. Also...how do you get it to submit when hitting "return" rather than needing a "search" submit button? Thanks! ...

javascript: define a variable if it doesn't exist

hey everybody, i feel like im trying to do something super simple, but just being stupid about it. all i want to do is see if a variable has been set previously, and if it has NOT, set it with a default value....here is a sample: if(!embed_BackgroundColor) { var embed_BackgroundColor; embed_BackgroundColor = "#F4F4F4"; } so, ...

Are there any rules regarding special characters/entities and innerHTML?

When I use innerHTML from javascript, the browser (Safari and Firefox at least) seem to replace certain characters and numeric entities with their named entities. The character \xa0 (non breaking space) gets replaced by  , < (lesser than) gets replaced by <. But for example the umlaut ü is not replaced with ü. I have...

How do I use Javascript to modify the content of a node?

I need to use Javascript to do three things: Select all nodes with a class of "foo". Find all words inside these nodes that begin with "*". Surround those words with <span class="xyz"> ... </span>, where xyz is the word itself. For example, the content: <ul> <li class="foo"> *abc def *ghi </li> <li class="bar"> abc *de...

WCF Newbie Question: Calling Methods from JavaScript

Greetings! I'm new to WCF and I thought it would be similar to ASP.NET web services, but I'm unable to call a method from client-side JavaScript. My web form looks like this: <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Path="...

How to set a javascript variable or reuse one from another function

I have a problem going on here and without going into a lot of detail and confusing everyone, let me just ask the simple question. Here are two functions. I need to use the "id" variable in the SubmitForm() function as well. Can someone please tell me how to do this? This is how new I am to js. :) Thanks for the help. AC.chooseFunc ...

Pass data to database using javascript Onclick

Hi all, I am a real noob when it comes to javascript/ajax, so any help will be very appreciated. In reference to this question: Updating a MySql database using PHP via an onClick javascript function But mainly concerned with the answer left by Phill Sacre. I am wondering if someone could elaborate on how we are(if we can?) passing va...

Serializing business objects as JSON

I'm trying to serialize my business objects into JSON for consumption by a Javascript application. The problem is is that I'm trying to keep my business objects "pure" in the sense they are not aware of data access or persistence. It seems to me that "diluting" my objects with a toJSON() function would go against this goal. On the other ...

Updating Database Using Javascript.

Hi all, Hopefully this will be the last question I need to ask about this..lol.. I cant be too far of the working solution(hopefully..lol). In reference to this question: Pass data to database using javascript Onclick I am trying to pass a value to the database using javascript. Below is the code i am using. And just for visual aid, I...

JQuery help with checkboxes and their values

Hi everyone. I am very new to javascript and JQuery but I managed to get my first ajax script almost working 100%. Maybe today will be my lucky day and I can finish this up. :) Let me give you guys a sample of each file so you know what is what. I believe that my last try at figuring this out was not successful because I was confusing t...

Undefined values for JQuery checkboxes

I have 3 checkboxes but they are showing as undefined in an alert box. Is there a trick to getting them to show a value? I tried putting a value of 1 in the input tag but it still reports as undefined. Ok, thanks.. Here is some code. else if (item.field == "admCustRptDly" && item.value == "1") { $('#admCustRpt...

Returning an array from JS to C# with COM-Interop

I'm returning some data from my JavaScript code to my C# code via COM Interop and the WebBrowser WPF control. I have successfully returned the data which looks like this in Javascript: var result = new Array(); result[0] = cbCamera.selectedItem; result[1] = cbMicrophone.selectedItem; Now I have the object result in C# which looks li...

Opening the webpage as if a link has been clicked from webpage

There is a webpage at this URL: http://www.vankampen.com/Products/529Portfolios This webpage opens with default option "With Sales Charge". There is a link "Without Sales Charge" on this webpage. When we click on this link then webpage displays options related with "Without Sales Charge". I want to open the "http://www.vankampen.com/P...

Detecting EOF / TCP teardown using Java sockets from Javascript

I'm creating a Java socket in Javascript, sending an HTTP request and receiving a response correctly but I seem to be unable to detect an EOF or the server closing the socket at the end. What am I doing wrong? The problem is we never exit the outermost while loop - the server stops transmitting and (presumably) closes its end of the conn...

How to remove an arbitrary element from a JavaScript array?

In my Google Maps application I can place markers on the map, and I keep a reference to each of the markers placed, along with some extra information in an array called markers. Adding markers is easy, I just push() the newly created object onto the array (markers.push(marker)); However, when it comes to removing an arbitrary marker fr...

AJAX and asp.net security question

Hello. I have a couple of questions regarding security mechanisms in asp.net (2.0). I have always been using Forms authentication + Page.User for validating permissions. Now I need to send some data from client side javaScript (jQuery) to a WCF service. Will my IPrincipal be still accessible from HttpContext of WCF service (I'm hosti...

Convert js Array() to JSon object for use with JQuery .ajax

Hi, in my app i need to send an javascript Array object to php script via ajax post. Something like this: var saveData = Array(); saveData["a"] = 2; saveData["c"] = 1; alert(saveData); $.ajax({ type: "POST", url: "salvaPreventivo.php", data:saveData, async:true }); Array's indexes are strings and not int, so for t...

What is your favourite JavaScript/jQuery code editor ?

What is the best and most powerful AJAX (including jQuery) code editor? I can use Visual Studio for that but want to know what NON MICROSOFT people are using to write their JavaScript, AJAX and jQuery code. ...

How to display javascript message based on which control fired AJAX?

I'm trying to figure out how to display a "Saved" message on the screen (with a fadeout effect courtesy of JQuery) whenever an AJAX call is made from a control that actually saves the form. The form is relatively complicated and has 5 seperate UpdatePanels where some--but not all--of the controls will do a post-back that will save the fo...

How do you organize Javascript verboseness?

Hey guys I am coding a GM script, and one thing I realised that I'm doing repeatedly is doing the same code over and over again. Specifically, the style property. function createButton() { var a = document.createElement('a'); a.href = '#'; a.innerHTML = 'Print Topic'; a.style.position = 'absolute'; a.style.right = '...