jan lee
08-23-2010, 01:34 PM
Hi
How can I add the contents from DIV ( <div id="results"></div> ) into an MSAccess database using ASP 3.0?
My script
_______
<html>
<head>
<title></title>
<script type="text/javascript">
function countWords(s) {
if (!window.wordCache) window.wordCache = [];
var arWords = s.match(/[\wáéóíñúü]+/gi);
for (var x = 0; x < arWords.length; x++) {
countWord(arWords[x]);
}
// report total counts;
document.getElementById("results").innerHTML = 'Totals:<p/>' +
'Total wordcount: ' + arWords.length + '<br/>';
for (var x = 0; x < window.wordCache.length; x++) {
document.getElementById("results").innerHTML +=
window.wordCache[x].word + ': ' +
window.wordCache[x].count + '<br/>';
}
}
function Word(val) {
this.word = val;
this.count = 1;
return this;
}
function countWord(word) {
var bExists = false;
// see if in wordCache
for (var x = 0; x < window.wordCache.length; x++) {
if (window.wordCache[x].word == word) {
window.wordCache[x].count += 1;
bExists = true;
}
}
// else add to wordCache
if (!bExists) window.wordCache[window.wordCache.length] = new Word(word);
}
</script>
</head>
<body>
<form>
<textarea name="t" rows="8" cols="35"></textarea><br>
<input type="button" name="" value="Count words" onclick="countWords(this.form.t.value);" />
<p/>
<div id="results"></div>
</form>
<body>
</html>
Jan Lee
How can I add the contents from DIV ( <div id="results"></div> ) into an MSAccess database using ASP 3.0?
My script
_______
<html>
<head>
<title></title>
<script type="text/javascript">
function countWords(s) {
if (!window.wordCache) window.wordCache = [];
var arWords = s.match(/[\wáéóíñúü]+/gi);
for (var x = 0; x < arWords.length; x++) {
countWord(arWords[x]);
}
// report total counts;
document.getElementById("results").innerHTML = 'Totals:<p/>' +
'Total wordcount: ' + arWords.length + '<br/>';
for (var x = 0; x < window.wordCache.length; x++) {
document.getElementById("results").innerHTML +=
window.wordCache[x].word + ': ' +
window.wordCache[x].count + '<br/>';
}
}
function Word(val) {
this.word = val;
this.count = 1;
return this;
}
function countWord(word) {
var bExists = false;
// see if in wordCache
for (var x = 0; x < window.wordCache.length; x++) {
if (window.wordCache[x].word == word) {
window.wordCache[x].count += 1;
bExists = true;
}
}
// else add to wordCache
if (!bExists) window.wordCache[window.wordCache.length] = new Word(word);
}
</script>
</head>
<body>
<form>
<textarea name="t" rows="8" cols="35"></textarea><br>
<input type="button" name="" value="Count words" onclick="countWords(this.form.t.value);" />
<p/>
<div id="results"></div>
</form>
<body>
</html>
Jan Lee