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


Groups > comp.lang.javascript > #40375

Re: changing the value of a text box with .js

From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.javascript
Subject Re: changing the value of a text box with .js
Date 2021-09-06 15:09 +0200
Message-ID <ipmi8nF3c0vU1@mid.individual.net> (permalink)
References <sh31k5$167f$1@gioia.aioe.org>

Show all headers | View raw


bill:

> I know how to change the value of a span or div using:
> onClick= document.getElementById("searchkey").value = "type min 3 
> letters";

<span> or <div> don't have a value. What are you talking about?

> but that does not work for an input type=text element.
> 
> What is the proper way to do that?

Using "value" is totally fine:

<input type="text" id="foobar" name="foobar">

<script>
document.getElementById("foobar").value="test";
</script>

However - where exactly do you use "onClick" and did you define
"searchkey" as *id* and not only as name?


-- 
Arno Welzel
https://arnowelzel.de

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

changing the value of a text box with .js bill <william@TechServSys.com> - 2021-09-05 14:17 -0400
  Re: changing the value of a text box with .js Jon Ribbens <jon+usenet@unequivocal.eu> - 2021-09-05 22:44 +0000
    Re: changing the value of a text box with .js JJ <jj4public@gmail.com> - 2021-09-06 14:39 +0700
      Re: changing the value of a text box with .js Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-09-17 00:46 +0200
  Re: changing the value of a text box with .js Arno Welzel <usenet@arnowelzel.de> - 2021-09-06 15:09 +0200

csiph-web