Wednesday, January 5, 2011

Wednesday, 1/05/11


<head>
<title>Check 1.1</title>
<script type="text/javascript">
window.onload = function(){
var keywordList = prompt("Enter keywords, seperated by commas", "");

var arrayList = keywordList.split(",");

var resultString = "";
for (var i = 0; i < arrayList.length; i++) {
resultString+="Keyword: " + arrayList[i] +
;
}

var blk = document.getElementById("result");
blk.innerHTML = resultString;
}
</script>
</head>
<body>
<div id="result">

</div>

</body>


"You can also use a regular expression as the parameter to split, thought this can be a bit tricky." - Shelley Powers

After much fussing and fighting, I got this to work:


<html>
<head>
<title>1.9 Processing individual lines of a text area</title>
<script type="text/javascript">

function ClipBoard()
{
alert("Hello!");
}

function doMethod()
{
alert("Processing!");
var txtBox = document.getElementById("test");
var lines = txtBox.value.split("\n");

var resultString ="

";
resultString += "Result: ";
for (var i =0; i < lines.length; i++)
{
resultString += lines[i] + "
";
}

var blk = document.getElementById("result");
blk.innerHTML = resultString;
}

</script>
</head>
<body>
<form>
<textarea id="test" onClick="ClipBoard();" rows="25" columns="25">

</textarea>
<br>
<br>
<input type="submit" id="submitButton" onClick="doMethod();" value="submit">
</form>
<p></p>

<textbox id="result">

</textbox>
</body>
</html>



my final tutorial for the day is from Michael Halvorston, on printing using Visual Basic


Imports System.Drawing.Printing

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Print using an error handler to catch problems
Try
'Declare PrintDoc variable of type PrintDocument
Dim PrintDoc As New PrintDocument
AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
PrintDoc.Print() 'print text
Catch ex As Exception
MessageBox.Show("Sorry--there is a problem printing", _
ex.ToString())
End Try
End Sub



Private Sub PrintText(ByVal Sender As Object, _
ByVal ev As PrintPageEventArgs)
'Use DrawString to create text in a Graphics object
ev.Graphics.DrawString(TextBox1.Text, New Font("Arial", _
11, FontStyle.Regular), Brushes.Black, 120, 120)
'specify that this is the last page to print
ev.HasMorePages = False
End Sub
End Class

No comments: