Rusty Javascript

Leave a comment Standard

Today I was having a total brain fart on my javascript abilities. So after some nifty google searching I was able to refresh my memory. If I’ve forgotten I’m sure you will too.

Declare A String

var result = new String(“my text goes in here”);

Substring Function

result.substring(0, 3); //pulls the first 3 characters off the string

Find All Child Field Of A DIV Layer

var children = document.getElementById(“div_id_here”).childNodes;

For Each Loop

for (var i in children) {
alert(children[i]);
}

Is Numeric Check

if (!isNAN(document.getElementById(“div_id_here”).value))
alert (“This really is a number!”);

Advertisements

Upcoming Programming Competitions – Win Big

Leave a comment Standard

Oct 3rd -4th: Wild Pocket Team Programming Competition – Pittsburgh & Harrisburg, PA. $2,500 to the best game.

July 1st – October 5th: IGDA Unreal Engine 3 Level Design Contest – Finalists get $50,000 and a demo at the South Miami, FL Infinite Bits Conventions.

Awesome Firefox Addons For Programmers

Leave a comment Standard

If you’re writing any kind of web-based program then these addons are for you as well. I use these pretty much every week, sometimes every day. Firefox is my browser of choice because it’s the most compliant so far and passes the ACID 2 and since it’s new update, nearly passes the ACID 3 test. Way to go Firefox!!

Web Developer – display information about the forms, view CSS info, highlight tables, clear sessions and so much more. By far my favorite.

Bottom Error Console – having the error console popup and then disapper any time you click on a page is flipping annoying. This saves you the time and trouble. Just click on it to show/hide the error console at the bottom of your screen.

Firebug Addon – edit, debug and monitor Javascript and CSS live.

Colorzilla – for all the times you wondered, what the hell color is that?!? Now you don’t have to take a screenshot and pull the color into a graphics program or lookup the color in the stylesheet (if you can). Now simply click on the eyedropper and the HEX code for the color shows up in your status bar.

SQL Injection – checks to see where you have vulnerable SQL injection fields/scripts in your forms.

SQL Inject Me – another SQL injection script that may find vulnerabilities the other one didn’t.

IE Net Render – Re-render your URL using IE standards right inside of Firefox. Now you don’t have to open another browser to see how messed up your CSS is in IE.

LoremTools – Copy Lorem text to your clipboard so you can paste filler text.

Cheat Sheet: ASP & PHP Cross Reference

Leave a comment Standard

I found this cool site that has examples cross-referencing PHP and ASP so you can see the difference (or use it if you’re switching from one language to the other). They also have a nifty ASP converter that will port ASP code into PHP code.

Classic ASP Tutorial: How to do Soap Requests

Comments 15 Standard

So I was having a helluva time trying to get this working. I was finally able to muck around and get a setup that would connect to SOAP at CapWiz like it’s supposed to. Almost all the examples I found were for AJAX and .Net. This code will work for classic ASP.  This example is setup to connect to CapWiz. If you want to use it for some other service simply change the namespace and url.

In order for this code to work as-is you’ll need a CapWiz account. If you run this code “as-is” you’ll send a SOAP request to CapWiz and get demographics from the elected individuals in Fairfax, VA in XML format.

<%
Dim objXMLHTTP : set objXMLHTTP = Server.CreateObject("Msxml2.XMLHTTP.3.0")
Dim strRequest, strResult, strFunction, strURL, strNamespace

'URL to SOAP namespace and connection URL
strNamespace = "http://capwiz.com/CapWiz/SOAP/Services"
strURL = "http://capwiz.com/soap/"

'function you want to call
strFunction = "get_demographics_electeddistricts"
'strFunction = "test" 'no parameters required

strRequest ="<?xml version=""1.0"" encoding=""utf-8""?>" _
& "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/""  xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/""" _
& "        xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">" _
& "    <SOAP-ENV:Body>" _
& "        <m:" & strFunction & " xmlns:m=""" & strNamespace & """>" _
& "            <authuser>YOUR_USERNAME_HERE</authuser>" _
& "            <authpass>YOUR_PASSWORD_HERE</authpass>" _
& "            <street>2751 Prosperity Ave</street>" _
& "            <city>Fairfax</city>" _
& "            <state>VA</state>" _
& "            <zip5>22031</zip5>" _
& "        </m:" & strFunction & ">" _
& "    </SOAP-ENV:Body>" _
& "</SOAP-ENV:Envelope>"

objXMLHTTP.open "post", "" & strURL & "", False

objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objXMLHTTP.setRequestHeader "Content-Length", Len(strRequest)

objXMLHTTP.setRequestHeader "SOAPAction", strNamespace & "#" & strFunction

'send the request and capture the result
Call objXMLHTTP.send(strRequest)
strResult = objXMLHTTP.responseText

'display the XML
response.write strResult
%>

I did use one reference from Experts Exchange.

get_demographics_electeddistricts