Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Friday, September 25, 2009

Poor Mans Nested Array Splitting

Some will laugh.  Some will scoff.  Some will snort and then realize they accidentally blew a booger on their shirt and say “oh damn”.  Oh well, here goes…

<%
Const myList = "1=RED,2=YELLOW,3=GREEN,4=CYAN,5=BLUE,6=MAGENTA"

Sub ColorNumList(default)
For each pair in Split(myList, ",")
x = Split(pair, "=")
If Cstr(default) = x(0) Then
Response.Write "<option value=" & x(0) & _
" selected>" & x(1) & "</option>"
Else
Response.Write "<option value=" & x(0) & _
">" & x(1) & "</option>"
End If
Next
End Sub
%>

To use this, you simply insert it within a matching set of ASP code tags inside of a <select></select> form object tag set:

...
<select name="colornum" size="1">
<% ColorNumList 3 %>
</select>
...

Sunday, July 12, 2009

ASP Get Page Input (Form or QueryString)


Function GetParam(strLabel)
Dim retval : retval = ""
retval = Trim(Request.Form(strLabel))
If retval = "" Then
retval = Trim(Request.QueryString(strLabel))
End If
GetParam = retval
End Function

Sunday, July 5, 2009

VBScript Scrape Links/IMG tags from URL


args = WScript.Arguments.Count

If args <> 1 Then
Wscript.Echo "usage: ScrapeLinks.vbs URL"
Wscript.Quit
End If

URL = WScript.Arguments.Item(0)

Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate URL

Do Until ie.ReadyState = 4
Wscript.sleep 10
Loop

Wscript.Echo "DOCUMENT LINKS"
Wscript.Echo

For each link in ie.Document.Links
Wscript.Echo link, link.InnerText
Next

Wscript.Echo
Wscript.Echo "DOCUMENT IMAGE TAGS"
Wscript.Echo

For each pix in ie.Document.Images
Wscript.Echo pix.Src
Next

ie.Quit
Set ie = Nothing