Wednesday, December 22, 2010

Wednesday, 12/22/10

Another tutorial out of the JavaScript Bible, which is really thorough.


<html>
<head>
<title>Writing to the Same Doc</title>
<script type="text/javascript">
function reWrite(){
// assemble content for new window
var newContent = "<html><head><title>A New Doc</title></head>";
newContent += "<body bgcolor='acqua'><h1>This document is brand new.</h1>";
newContent += "

Click the back button to see the original document.</P>";
newContent += "</body></html>";
//write HTML to new Window document
document.write(newContent);
document.close(); //close layout stream
}
</script>
</head>
<body>
<form>
<<input type="button" value="Replace Content" onclick="reWrite()">
</form>
</body>
</html>



Here is another tutorial from the JavaScript bible



<html>
<head>
<title>Writing to Subwindow</title>
<script type="text/javascript">

function makeNewWindow() {
newWindow = window.open("","new window","height=200,width=300");
define()
}

function define(){
var newContent="<html><head><title>The New document</title></head>";
newContent +="<body bgcolor='coral'; padding=25px><h1>This document is brand new.</h1>";
newContent +="</body></html>"
newWindow.document.write(newContent)
newWindow.document.close(); // close layout stream
}
</script>

</head>
<body>
<input type="button" value="Write to Subwindow" onclick="makeNewWindow()">

</body>

</html>


Here is another tutorial working with textboxes


<html>
<head>
<title>Checkbox Inspector</title>
<script type="text/javascript">
function inspectBox() {
if (document.forms[0].checkThis.checked) {
alert("The box is checked.");
} else {
alert("The box is not checked at the moment.");
}
}
</script>

</head>
<body>
<form>
<input type="checkbox" name="checkThis">Check here

<input type="button" value="Inspect Box" onclick="inspectBox()">

</form>
</body>
</html>


And this tutorial deals with a group of radio objects


<html>
<head>
<title>Extracting Highlighted Radio Button</title>
<script type="text/javascript">
function fullName() {
var form = document.forms[0];
for (var i = 0; i < form.stooges.length; i++) {
if (form.stooges[i].checked) {
break;
}
}
//the break statement bails out of the FOR loop, leaving the value of the i loop counter at the number where the loop broke ranks
alert("You chose " + form.stooges[i].value + ".");
}
</script>
</head>

<body>
<form>
<P>Select your favorite Stooge:
<input type="radio" name="stooges" value="Moe Howard" checked>Moe
<input type="radio" name="stooges" value="Larry Fine">Larry
<input type="radio" name="stooges" value="Curly Howard">Curly<br>
<input type="button" name="viewer" value="View Full Name..."
onclick="fullName()">


//The onclick event handler invokes the fullName() function
<


</form>
</body>

</html>


Switching back to Visual Basic, here is a tutorial on dynamically adding items to a combo box.


Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim itm As String
itm = InputBox("Enter new item", "New Item")
If itm.Trim <> " " Then AddElement(itm)
End Sub

Sub AddElement(ByVal newItem As String)
Dim idx As Integer
If ComboBox1.FindString(newItem) > 0 Then
idx = ComboBox1.FindString(newItem)
Else
idx = ComboBox1.Items.Add(newItem)
End If
ComboBox1.SelectedIndex = idx
End Sub

Private Sub ComboBox_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus
Dim newItem As String = ComboBox1.Text
AddElement(newItem)
End Sub


Here is part of a large project by Tim Patrick, it is the first module I have ever worked with


Friend Module General
Public Const ProgramTitle As String = "The Library Project"
Public Const NotAuthorizedMessage As String = _
"You are not authorized to perform this task."
Public Const UseDBVersion As Integer = 1

' --- Constants for the MatchingImages image list
Public Const MatchPresent As Integer = 0
Public Const MatchNone As Integer = 1
Public Enum LookupMethods As Integer
ByTitle = 1
ByAuthor = 2
BySubject = 3
ByKeywordAny = 4
ByKeywordAll = 5
ByPublisher = 6
BySeries = 7
BySeriesID = 8
ByBarcode = 9
ByDatabaseID = 10
ByAuthorID = 11
BySubjectID = 12
ByPublisherID = 13
End Enum

Public Enum LibrarySecurity As Integer
ManageAuthors = 1
ManageAuthorTypes = 2
ManageCopyStatus = 3
ManageMediaTypes = 4
ManageSeries = 5
ManageGroups = 6
ManageItems = 7
ManagePatrons = 8
ManagePublishers = 9
ManageValues = 10
ManageUsers = 11
ProcessFees = 12
ManageLocations = 13
CheckOutItems = 14
CheckInItems = 15
AdminFeatures = 16
DailyProcessing = 17
BunReports = 18
PatronOverride = 19
ManageBarcodeTemplates = 20
ManageHolidays = 21
ManagePatronGroups = 22
ViewAdminPatronMessages = 23
End Enum

Public Const MaxLibrarySecurity As LibrarySecurity = LibrarySecurity.ViewAdminPatronMessages

No comments: