...

View Full Version : Using a loop to process multiple lines of input.



fuhrmann
08-31-2006, 08:24 PM
I want to know if the following is possible and if someone could show me the code that is needed.

I have HTML code to go out to a server and get PDF documents from our (work) storage area.
I would like to be able to have an open text input where I can type in document names (one per line) and have the program run the code for each document name and open a new window to display the documents.

The code that gets me one document from the storage area is:

<form action="http://server_name/cgi-bin/pdm/view.cgi" method=GET enctype="application/x-www-form-urlencoded">

<INPUT TYPE="text" SIZE="10" NAME="name">

<INPUT TYPE="hidden" NAME="ext" VALUE="PDF">

<INPUT TYPE="submit" ACTION="http://server_name/cgi-bin/pdm/view.cgi" VALUE=". PDF" METHOD="GET">

</form>

This opens the document in the current window with Acrobat.
We are using IE6

I don't need a lot of error testing or for the routine to be user friendly, this is for my personal use to speed up my work. (The worst programs that I have ever seen were written by engineers for themselves.)

It is ok if a bad document name opens blank window or not at all.

The current code doesn't choke on bad document names, the screen just doesn't change.

My skill level - really rank beginner. I have learned enough HTML to handle minimal tasks. I have hacked out a couple of minimal web sites and gotten the code above to work.

I am a competent programmer in the old languages (Fortran, Quick Basic compiler). I.E. I understand things like looping and looking for the end of a list.

rlemon
09-01-2006, 06:51 PM
so you want to read the two form inputs?

or are there multiple forms structured the same way?

ii'm sorry i'm not fully following you here.

fuhrmann
09-01-2006, 09:34 PM
No, just one list input (one document name per line) that will then send a series of commands as if I typed a series of single name inputs.

I cannot open the files directly. The "view.cgi" goes to the server and gets the most recent revision of the document.

If I want to scan through 40 items (often I can tell within a couple seconds if the document, engineering drawings, needs to be looked at farther), I need to either call them up one at a time or go through another routine where I can print them as a batch.

One way might be to generate new windows that have the view.cgi command already filled in and launched. It would even be an improvement if they were created and I still needed to press enter on each one.

That way I can create a stack of PDF files on my desktop and close the ones I don't need.

Bill Fuhrmann

rlemon
09-05-2006, 02:58 PM
ok i think i get it now.



function textareaToArray(t)
{
return t.value.split(/[\n\r]+/);
}
function runLines(ta)
{

for(i = 0; i < ta.length; i++)
{
var newWin=window.open('','name','height=400,width=500');
newWin.document.write('<html><head><title>Popup</title></head><body>');
newWin.document.write('<form action="http://server_name/cgi-bin/pdm/view.cgi" method=GET enctype="application/x-www-form-urlencoded">');
newWin.document.write('<INPUT TYPE="text" SIZE="10" NAME="name" VALUE="' + ta + '">');
newWin.document.write('<INPUT TYPE="hidden" NAME="ext" VALUE="PDF">');
newWin.document.write('</form>');
newWin.document.write('</body></html>');
newWin.document.close();
newWin.document.forms[0].submit();
}
}


ok, you'll need a textarea, and a button.

onClick get the array of lines from the textarea and process them with runLines(ta) where ta is the textArray.

let me know if that doesn't work for you.

fuhrmann
09-05-2006, 03:29 PM
THANKS! :thumbsup:

Haven't tried it yet but the logic looks to be what I was looking for.

It may be a little bit before I get time to try it out.

It looks like I need to run
textareaToArray(t) (to convert the text area into Array TA
then run
runLines(ta) (to create the display windows for each item).

Can they be combined into one routine?

Bill Fuhrmann

rlemon
09-05-2006, 04:24 PM
THANKS! :thumbsup:

Haven't tried it yet but the logic looks to be what I was looking for.

It may be a little bit before I get time to try it out.

It looks like I need to run
textareaToArray(t) (to convert the text area into Array TA
then run
runLines(ta) (to create the display windows for each item).

Can they be combined into one routine?

Bill Fuhrmann

try...


function runLines(t)
{
var ta = t.value.split(/[\n\r]+/)
for(i = 0; i < ta.length; i++)
{
var newWin=window.open('','name','height=400,width=500');
newWin.document.write('<html><head><title>Popup</title></head><body>');
newWin.document.write('<form action="http://server_name/cgi-bin/pdm/view.cgi" method=GET enctype="application/x-www-form-urlencoded">');
newWin.document.write('<INPUT TYPE="text" SIZE="10" NAME="name" VALUE="' + ta + '">');
newWin.document.write('<INPUT TYPE="hidden" NAME="ext" VALUE="PDF">');
newWin.document.write('</form>');
newWin.document.write('</body></html>');
newWin.document.close();
newWin.document.forms[0].submit();
}
}


<textarea name="myTA" id="myTA"></textarea><br />
<input type="button" value="run" onclick="runLines(document.getElementById('myTA').value)" />



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum