Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #37879 > unrolled thread

Get user input without PHP code?

Started byRG III <mob.rrr.3@gmail.com>
First post2019-11-27 11:56 -0800
Last post2019-11-29 11:49 +0100
Articles 7 — 7 participants

Back to article view | Back to comp.lang.javascript


Contents

  Get user input without PHP code? RG III <mob.rrr.3@gmail.com> - 2019-11-27 11:56 -0800
    Re: Get user input without PHP code? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2019-11-27 13:34 -0700
    Re: Get user input without PHP code? Robert Heller <heller@deepsoft.com> - 2019-11-27 15:09 -0600
    Re: Get user input without PHP code? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-11-27 14:49 -0800
    Re: Get user input without PHP code? JJ <jj4public@vfemail.net> - 2019-11-28 23:44 +0700
      Re: Get user input without PHP code? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-11-28 18:42 +0100
    Re: Get user input without PHP code? Arno Welzel <usenet@arnowelzel.de> - 2019-11-29 11:49 +0100

#37879 — Get user input without PHP code?

FromRG III <mob.rrr.3@gmail.com>
Date2019-11-27 11:56 -0800
SubjectGet user input without PHP code?
Message-ID<1fd6cda2-34cc-4389-93b9-1ac2176c8afd@googlegroups.com>
I've been away from HTML/JavaScript/PHP coding for awhile, so I don't know how much has changed in the web coding world... I'm just curious, but are there any HTML or JavaScript methods for getting user input without using input forms or PHP back-end coding?

-Robert

[toc] | [next] | [standalone]


#37881

FromMartin Leese <please@see.Web.for.e-mail.INVALID>
Date2019-11-27 13:34 -0700
Message-ID<qrmmk8$tl8$1@dont-email.me>
In reply to#37879
RG III wrote:
> I've been away from HTML/JavaScript/PHP coding for awhile, so I don't know how much has changed in the web coding world... I'm just curious, but are there any HTML or JavaScript methods for getting user input without using input forms or PHP back-end coding?

If this was a PHP group, such as
comp.lang.php, then I would have asked how
you do that with "PHP back-end coding?".
However as it isn't, I wont.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/

[toc] | [prev] | [next] | [standalone]


#37882

FromRobert Heller <heller@deepsoft.com>
Date2019-11-27 15:09 -0600
Message-ID<vZmdndWRPeyce0PAnZ2dnUU7-SvNnZ2d@giganews.com>
In reply to#37879
At Wed, 27 Nov 2019 11:56:40 -0800 (PST) RG III <mob.rrr.3@gmail.com> wrote:

> 
> I've been away from HTML/JavaScript/PHP coding for awhile, so I don't know =
> how much has changed in the web coding world... I'm just curious, but are t=
> here any HTML or JavaScript methods for getting user input without using in=
> put forms or PHP back-end coding?

If the back end (server) needs to process the input, then you need some 
back-end coding.  No reason it has to be PHP.  There are other active server 
processing technologies.

Getting input from the user pretty much needs at least <input .../>, <select 
..> or <textarea ...> tags.  Whether or not they are in a <form...> or not 
depends...

> 
> -Robert
>                                                        

-- 
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller@deepsoft.com       -- Webhosting Services
                           

[toc] | [prev] | [next] | [standalone]


#37884

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2019-11-27 14:49 -0800
Message-ID<f8c85525-f861-448c-ae67-208eb62c6698@googlegroups.com>
In reply to#37879
On Wednesday, November 27, 2019 at 1:56:48 PM UTC-6, RG III wrote:
> I've been away from HTML/JavaScript/PHP coding for awhile, so I don't know how much has changed in the web coding world... I'm just curious, but are there any HTML or JavaScript methods for getting user input without using input forms or PHP back-end coding?
> 

Some context would be helpful otherwise a trivial example is:

```
let result = window.prompt("Enter Age",18)
```

And that functionality has existed as long as I can remember...

[toc] | [prev] | [next] | [standalone]


#37886

FromJJ <jj4public@vfemail.net>
Date2019-11-28 23:44 +0700
Message-ID<w5bmsjajroil.vdgzdmfek55v$.dlg@40tude.net>
In reply to#37879
On Wed, 27 Nov 2019 11:56:40 -0800 (PST), RG III wrote:
> I've been away from HTML/JavaScript/PHP coding for awhile, so I don't know
> how much has changed in the web coding world... I'm just curious, but are
> there any HTML or JavaScript methods for getting user input without using
> input forms or PHP back-end coding?
> 
> -Robert

If it's just text input, then aside from what already have been mentioned,
additionally, `keypress` or `keydown` event can be used to listen for key
presses. At the proper time, of course. Then send the text to the server
using AJAX.

However, if it's a file input, you'll have to use an INPUT element (of
`file` type - with or without FORM element). There's no other way around it.

[toc] | [prev] | [next] | [standalone]


#37888

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2019-11-28 18:42 +0100
Message-ID<11431325.O9o76ZdvQC@PointedEars.de>
In reply to#37886
JJ wrote:

> On Wed, 27 Nov 2019 11:56:40 -0800 (PST), RG III wrote:
>> I've been away from HTML/JavaScript/PHP coding for awhile, so I don't
>> know how much has changed in the web coding world... I'm just curious,
>> but are there any HTML or JavaScript methods for getting user input
>> without using input forms or PHP back-end coding?
> 
> If it's just text input, then aside from what already have been mentioned,
> additionally, `keypress` or `keydown` event can be used to listen for key
> presses. At the proper time, of course. Then send the text to the server
> using AJAX.

This advice is outdated in several respects.

It is better to listen to the “beforeinput” and “input” events, and to the 
“keypress” event only as a fallback, because the former are only fired if 
something changes without the input control losing focus; and they are also 
fired if text is edited using the clipboard (using either a keyboard or a 
pointing device), which is not always and everywhere the case with the 
“keypress”, “keydown” and “keyup” events.

Notably, the “keydown” event and the (not mentioned, but more appropriate 
than that) “keyup” event, and sometimes the “keypress” event, are also fired 
if the value of a control does not change, for example if the Backspace key 
is pressed in an empty input control or a key is pressed in an 
input/textarea control but the maximum number of allowed characters has been 
reached (“maxlength” attribute).  So using those events in client–server 
communication incurs an unnecessary load on the server.

Finally, (outside the jQuery information bubble) nowadays one no longer 
speaks of “AJAX” (which once meant “Asynchronous JavaScript and XML”), but 
of submitting data or fetching a Web resource asynchronously (via HTTP), 
preferably using the Fetch API; where it should be noted that ECMAScript 
2018 introduced the “await” operator and “async” keyword as syntactic sugar 
for processing the returned promise (no more callbacks for simple tasks):

  (async function () {
    var response = await fetch('/query?format=json');
    var obj = await response.json();

    /* executed after the response was received */
    console.log(obj);
  }());

  /* executed before the response is received */
  console.log(42);
​
<https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event>

<https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event>

<https://developer.mozilla.org/en-US/docs/Web/API/Document/keypress_event> 
(deprecated)

<https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API>

<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await>
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#37906

FromArno Welzel <usenet@arnowelzel.de>
Date2019-11-29 11:49 +0100
Message-ID<h4cbd3FqqoqU2@mid.individual.net>
In reply to#37879
On 27.11.19 20:56, RG III wrote:

> I've been away from HTML/JavaScript/PHP coding for awhile, so I don't
> know how much has changed in the web coding world... I'm just
> curious, but are there any HTML or JavaScript methods for getting
> user input without using input forms or PHP back-end coding?

Yes.


-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web