on my way out to my daughter's basketball game.
will pick this up later tonight.
jwd
Printable View
on my way out to my daughter's basketball game.
will pick this up later tonight.
jwd
Ok,
here is my second page. Instead of returning to the first page, I need to insert it into the db from here.
Thanks for your help!Code:if (test == 1) {
var x = data.split(/\+/g);
while((newmsg+x[m]).length<41){
newmsg=newmsg+x[m]+" ";
m++;
}
var insertSQL="INSERT INTO WHATEVER"; //insert newmsg here and the count of 40 char lines, we will call it i.
cnConn.Execute(insertSQL);
Response.Write("I should be working");
i++;
}
just got in. are you familiar with the javascript function remove()?
question: due to db issue will you need to insert each chunk independently and you will need to identify the common key that will allow the 'windows app' you referred to yesterday to identity and retrieve all the msg parts into a unified display. Am I making sense?
Never heard of remove. I have heard of replace though.
Ignore quoted bit above - brain fade:Quote:
Oops! sorry mixing my languages again.
the trick would be to use a regular Expression to compare the captured chunk (newmsg) to the original string (msg) and using replace() the clear out the captured bit and leave behind the unprocessed bit which in turn is then reprocessed. From a coding modularity pov I would write a separate function to do this, just the keep these apart and adaptive.
We are working with an array. So once we have determined which elements of the initial array we are using to build the first string chunk we need to get the original array (msg) and remove the elements used. I think this is leading to using the array method splice() to pull out the already processed parts and then we can reprocess the array to get this next chunk.
Whew! need some coffee ..
Whew! I can't figure it out.
Here is what I am wanting to do with the insert:
Help. My brain is about ready to fry....Code:for (var i = 0; i < myArray.length; i++) {
var insertSQL="INSERT INTO SOMETHING(DATA, LINE) VALUES ('myArray[i] +"','"+ i +"')";
conn.Execute(insertSQL);
I am working with the code that you gave me but inserting each return that I get into an array so that I can then insert each line into the DB.
With a little syntax highlighting you'll see the myArray[i] in your code is actually part of the SQL string, and is not being evaluated by JavaScript. You want to end the quote, put the JavaScript var, then begin the quote again:PHP Code:var insertSQL="INSERT INTO SOMETHING(DATA, LINE) VALUES ('myArray[i] +"','"+ i +"')";
PHP Code:var insertSQL="INSERT INTO SOMETHING(DATA, LINE) VALUES ('"+myArray[i]+"','"+ i +"')";
you appear to be in good hands with tiocontien
I haven't worked out all the loops and recursion (you seem to have that ) but here is a bunch of javascript functions that may or may not be useful.
Code:<script>
var msg="";
var newmsg="";
var m=0;
var leader="";
var lines_array=[];
//get the textarea content, clip off the key and =, split into an array of whole word. If a word is followed by any punctuation it will be included in the word.
function getQueryString(){
msg = window.location.search;
msg = msg.substring(1);
msg = msg.split("=");
msg = msg[1].split(/\+/g);
}
//process msg to find and isolate the chunk
function buildInsertStr(msg){
while ((newmsg+msg[m]).length<41){
newmsg=newmsg+msg[m]+" ";
m++;
}
return newmsg;
}
//strip off the last captured chunk
function removeLeaderStr(){
msg.splice(0,m);
return msg;
}
//insert last captured chuck in a new array called lines_array
function buildInsertArray(newmsg){
lines_array.push(newmsg);
}
function buildDBInsert(){
//msg_array is input after all the others function has recursed through the array to words to create and array of string where: each x is one of them
}
</script>
Everything except the INSERT statement ....
Left a document.write in my buildDBInsert just for demo.
Code:<html>
<head>
<script>
var msg="";
var currmsg="";
var newmsg="";
var m=0;
var leader="";
var lines_array=[];
//get the textarea content, clip off the key and =, split into an array of whole word. If a word is followed by any punctuation it will be included in the word.
function getQueryString(){
msg = window.location.search;
msg = msg.substring(1);
msg = msg.split("=");
msg = msg[1].split(/\+/g);
currmsg=msg;
buildInsertStr(currmsg);
}
//process msg to find and isolate the chunk
function buildInsertStr(currmsg){
while ((newmsg+currmsg[m]).length<41){
newmsg=newmsg+currmsg[m]+" ";
m++;
}
buildInsertArray(newmsg);
}
//insert last captured chuck in a new array called lines_array
function buildInsertArray(newmsg){
lines_array.push(unescape(newmsg));
removeLeaderStr();
}
//strip off the last captured chunk
function removeLeaderStr(){
currmsg.splice(0,m);
if(currmsg.length>0){
m=0;
newmsg="";
buildInsertStr(currmsg);
}else{
buildDBInsert();
}
}
function buildDBInsert(){
//msg_array is input after all the others function has recursed through the array to words to create and array of string where: each x is one of them
for (var i = 0; i < lines_array.length; i++) {
//var insertSQL="INSERT INTO SOMETHING(DATA, LINE) VALUES ('"+lines_array[i]+"','"+ i +"')";
document.write(lines_array[i]+"<br />");
}
}
</script>
</head>
<body>
<script>
getQueryString()
</script>
</body>
</html>
Awesome!! javawebdog, I actually got everything working before you posted your last items. I just want to Thank You! for all of your help, without it I probably wouldn't have been able to accomplish this. But now I am getting a lot better at Javascript, which could be dangerous. LOL
Off topic, I live in south-eastern ohio. I am glad someone else in ohio was able to help me out.