From: David Mark on
On Aug 1, 7:17 pm, jr <jlro...(a)yahoo.com> wrote:
> On Aug 1, 4:05 pm, David Mark <dmark.cins...(a)gmail.com> wrote:
>
>
>
>
>
> > On Aug 1, 6:56 pm, Captain Paralytic <paul_laut...(a)yahoo.com> wrote:
>
> > > On Aug 1, 12:52 pm, David Mark <dmark.cins...(a)gmail.com> wrote:> LOL.  You really think this "jr" guy is using XML parse mode?
>
> > > This jr guy is a girl. Janis or Jane Rough.
>
> > Mea culpa.  I must have mistaken her for another "JR" (or "jr").  Hard
> > to tell with such non-specific handles.
>
> > > She has been trying to program for 10 years and still can't master the
> > > basics.
>
> > I'm sorry to hear that.  I thought she was an absolute beginner.
>
> > > Check out her posting profile in Google groups and you'll see what I
> > > mean.
>
> > I'll pass.
>
> Excuse me but CP is incorrect.  I was doing Filemaker databases for 10
> years.

Okay.

> That is not programming.

What is not programming?
From: jr on
On Aug 1, 8:41 am, Denis McMahon <denis.m.f.mcma...(a)googlemail.com>
wrote:
> On 01/08/10 16:20, jr wrote:
>
>
>
>
>
> > On Aug 1, 2:12 am, Denis McMahon <denis.m.f.mcma...(a)googlemail.com>
> > wrote:
> >> On 01/08/10 05:04, jr wrote:
>
> >>> <script type="text/javascript">
> >>> function printFromHere(){
>
> >>> var xhr = document.forms[0].search_zonenm.value;
> >>>                 if ( window.XMLHttpRequest ) {// code for IE7+,
> >>> Firefox, Chrome, Opera, Safari
> >>>              xhr=new XMLHttpRequest();
> >>>            }else{ // code for IE6, IE5
> >>>              xhr=new ActiveXObject("Microsoft.XMLHTTP");
> >>>            }
>
> >> What is the purpose of xhr in your code? Is it to hold the
> >> XMLHttpRequest object, or to hold the value of field
> >> document.forms[0].search_zonenm.value?
>
> >> See my earlier response to the original thread about this code for other
> >> issues.
> > xhr is needed to check the value of the readystate, right?
> > I did change it from assigning the printer_response to the
> > responseText to the innerHTML of the getElementByID function.  thanks,
> >  document.getElementById('printer_response').innerHTML="Received:"  +
> > xhr.responseText;
>
> An object to handle the data exchange is needed, yes, but it doesn't
> have to be called any specific name.
>
> Let me clarify my earlier question:
>
> First you do this:
>
> >>> var xhr = document.forms[0].search_zonenm.value;
>
> which assigns some value from a form field to the variable "xhr"
>
> Then you do this:
>
> >>> if ( window.XMLHttpRequest ) { // IE7+ ff chrome etc
> >>>     xhr=new XMLHttpRequest();
> >>> }else{ // IE6, IE5
> >>>     xhr=new ActiveXObject("Microsoft.XMLHTTP");
> >>> }
>
> which assigns your data exchange object to "xhr"
>
> Now, which one of these two is xhr meant to be, and whichever one it is,
> what is the correct name of the variable that you wish to assign to the
> other one.
>
> For all the regulars, how long before jr asks for help in working out
> why xhr doesn't contain a string representing
> "document.forms[0].search_zonenm.value"?
>
> Rgds
>
> Denis McMahon

I apologize, I left that first var xhr there in error because I was
trying to figure out how to get var $response back to
the display page from the print_test.php page. How do I go about
that or does that have to be another XMLHTTPrequest ? Maybe that is a
question for the php usenet group?
So I get a respose from the FTP printer, which says FTP connected or
FTP failed, that is a var fromthe printer_test.php page. It would be
great if I could get that response and display it to the user in the
<div> id="printer_response" <div>.

Here is the function
function printFromHere(){

var response ;

if ( window.XMLHttpRequest ) {// code for IE7+,
Firefox, Chrome, Opera, Safari
xhr=new XMLHttpRequest();
}else{ // code for IE6, IE5
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200)

document.getElementById('printer_response').innerHTML="Received:" +
xhr.responseText;
else
document.getElementById('printer_response').innerHTML
="Error code " + xhr.status;
}
}
xhr.open(GET, "print_test.php", true);
xhr.send(null);
}


This is the submit button in the form,

<input type="submit" name="print" value="Print labels on this page"
onsubmit="printFromHere();"/></form></body>
</html>
Rgds,
Janis
From: jr on
On Aug 1, 4:03 pm, David Mark <dmark.cins...(a)gmail.com> wrote:
> On Aug 1, 10:54 am, "Richard Cornford" <Rich...(a)litotes.demon.co.uk>
> wrote:
>
>
>
>
>
> > Thomas 'PointedEars' Lahn" wrote:
> > > David Mark wrote:
> > >> jr wrote:
> > >>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> > >>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
> > >> Why are you using XHTML when IE doesn't support it?  Clearly
> > >> you are relying on error correction to turn it into HTML.
>
> > > That assumption cannot be made from the posting.
>
> > <snip>
>
> > In the event that this document is being interpreted as XHTML by the
> > browser, the:-
>
> > | <input type="button" ... onClick="printFromHere();"/>
> >                            ^^^^^^^
> > - in the mark-up is sufficient to explain why clicking the button is not
> > resulting in any apparent action.
>
> It's a gEBI snafu from the bit of code I looked at.  At a glance, I
> don't think his markup would even parse as XHTML.
>
>
>
> > However, that does suggest a reliance on the document being interpreted
> > as HTML (and so error corrected), but possibly a reliance that is
> > disappointed by the document actually being interpreted as XHTML.
>
> That would be another possibility, but I think it is less than a
> favorite in this case.
P.S. I don't need to exchange any GET or POST data in this case with
the print_test.php page. I only need to print the labels on this page.
The data is written to a template text file. That file is FTP'd to a
zebra printer when the print_test.php page is called. I would like
some information on the handshake.
The AJAX just allows the user to click the button for all the pages
from the display page and not have to keep clicking the back button
from the print_test.php page.
There are pages and pages of labels. So what I really want to do is
to call the print_test.php that FTPs the template text file from
the display page. If I get a status 200 that should let me know the
page got called but I really need the $response var from that page to
be passed back to the display page. Right now what is happening when
I click the button is it eliminates the current data displayed and
only gives me the empty form?


From: Denis McMahon on
On 02/08/10 00:55, jr wrote:

> This is the submit button in the form,
>
> <input type="submit" name="print" value="Print labels on this page"
> onsubmit="printFromHere();"/>

Is "onsubmit" a valid event for an object of type submit? I thought it
was a form event.

I'm not sure whether you want to submit data from this form to the php
page that triggers the print operation or not. Clarification of that
might help. If you do, then to use an ajax request, you will have to use
javascript to assemble a full post or get request from the form data
when the button is clicked. It may be better to use a traditional form
submit and generate a new page with the printer response message on the
server.

If the data is already on the server, you don't need to use a form for
this, although how does the server know which data to use? Session
cookies? Job id from the form (which you might need to append to the get
request using ?field=value)? In either case, you probably shouldn't be
triggering ajax requests from a form's submit button using an onsubmit
handler.

You could use the form's onsubmit handler to specify javascript to
execute when the submit button is pressed. Perhaps that's what you want
to do? If you do that, and don't want to execute the form's action, make
sure your javascript returns false.

Your submit button is probably trying to call it's parent form's action,
unless your "onsubmit='blah'" is confusing it completely.

Perhaps you should use a normal button (rather than a submit) and give
it a value of, for example, "Send to Printer" and, perhaps, use an
appropriate event handler to call the javascript code.

If I had a better understanding of what you were attempting, I might be
able to give better and / or less confusing pointers to possible solutions.

The following javascript and html, if you understand what it shows,
might be useful to you, or it might not. If you don't understand it, but
instead just blindly copy parts, or all, of it, and things still don't
work, well you obviously didn't take the time to try and understand it
first!

<script type="text/javascript">
function clanger() {
// visit the soupdragon
var soupdragon;
if (window.XMLHttpRequest) { // ie7+ etc
soupdragon=new XMLHttpRequest();
}else{ // IE6, IE5
soupdragon=new ActiveXObject("Microsoft.XMLHTTP");
}
soupdragon.onreadystatechange = function()
{
if(soupdragon.readyState == 4)
{
if(soupdragon.status == 200)
document.getElementById('printer_response').innerHTML=
"Received: " + soupdragon.responseText;
else
document.getElementById('printer_response').innerHTML=
"Error code: " + soupdragon.status;
}
}
soupdragon.open(GET, "print_test.php", true);
soupdragon.send();
return false;
}
</script>

<form action="blah" method="whatever" onsubmit="clanger()">
...... fields .....
<input type="submit">
</form>

Rgds

Denis McMahon
From: jr on
On Aug 1, 4:51 pm, David Mark <dmark.cins...(a)gmail.com> wrote:
> On Aug 1, 7:17 pm, jr <jlro...(a)yahoo.com> wrote:
>
>
>
>
>
> > On Aug 1, 4:05 pm, David Mark <dmark.cins...(a)gmail.com> wrote:
>
> > > On Aug 1, 6:56 pm, Captain Paralytic <paul_laut...(a)yahoo.com> wrote:
>
> > > > On Aug 1, 12:52 pm, David Mark <dmark.cins...(a)gmail.com> wrote:> LOL.  You really think this "jr" guy is using XML parse mode?
>
> > > > This jr guy is a girl. Janis or Jane Rough.
>
> > > Mea culpa.  I must have mistaken her for another "JR" (or "jr").  Hard
> > > to tell with such non-specific handles.
>
> > > > She has been trying to program for 10 years and still can't master the
> > > > basics.
>
> > > I'm sorry to hear that.  I thought she was an absolute beginner.
>
> > > > Check out her posting profile in Google groups and you'll see what I
> > > > mean.
>
> > > I'll pass.
>
> > Excuse me but CP is incorrect.  I was doing Filemaker databases for 10
> > years.
>
> Okay.
>
> > That is not programming.
>
> What is not programming?

Filemaker is not a programming language. I feel like the statements
he is making about me are false.