Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need one more tweak...

1 view
Skip to first unread message

Levan, Jerry

unread,
Jan 20, 2011, 3:43:50 PM1/20/11
to Mac OS X perl
Hi,

I am almost done with my quest for a way to interact with
a postgresql database with a Perl CGI.

I am trying to find a way to interact with my
database via my iPad and web access seems to be
the key.

I basically have a form with a text box, users
can enter sql in the text box and hit the submit
button and the Perl CGI will do its magic on all of
the text in the box.

Query results will appear as html tables.

I would like one more enhancement...

I would like to be able to 'select' some text in
the text box and using possibly a different
submit button have the CGI code only process the
selected text.

My gut feeling is that this might involve using
javascript which is bad since it has been about
Fifteen years since I have written any js code....

Can anyone offer any guidance?

What I have now works well and looks good (to me)
on the iPad but I think that being able to select
text to 'execute' will improve the work flow.

Thanks

Jerry


John Delacour

unread,
Jan 20, 2011, 4:34:11 PM1/20/11
to Levan, Jerry, Mac OS X perl
At 15:43 -0500 20/01/2011, Levan, Jerry wrote:

>I basically have a form with a text box, users
>can enter sql in the text box and hit the submit
>button and the Perl CGI will do its magic on all of
>the text in the box.
>
>Query results will appear as html tables.
>
>I would like one more enhancement...
>
>I would like to be able to 'select' some text in
>the text box and using possibly a different
>submit button have the CGI code only process the
>selected text.
>
>My gut feeling is that this might involve using
>javascript which is bad since it has been about
>Fifteen years since I have written any js code....

I am halfway through doing a very similar thing and found a suitable
script on my first attempt.

I append the subroutine I have used to insert the script into the
<head> and below it the stuff for the button. At present I have it
only inserting the selection into text box "selected_ix" in form
"aform" but the routine will be elaborated soon to post the query.
I'm sure you can work it out if I can, since I'm practically
javascript illiterate.

sub SCRIPT_GET_SELECTED_TEXT{
my $s= qq~
<script type="application/ecmascript" charset="utf-8">
// <![CDATA[
function getSelText()
{
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return;
document.aform.selected_ix.value = txt;
}
// ]]>
</script>
~;
return $s;
}

<input type="BUTTON" value="Enter selected"
method="post" action="icsql.pl" enctype="multipart/form-data"
onmousedown="getSelText()">


0 new messages