Changing text in input text box

  • Thread starter Thomas 'PointedEars' Lahn
  • Start date
T

Thomas 'PointedEars' Lahn

Butterfly said:
There has to be some way you can change the words you have put into a
<input type="text box because I have seen on-screen calculators that
can put your result into one. But I can't find the exact way among all
the entries in the lists of objects and other stuff. It seems to have
something with declaring a different value for the value=" part of it,
but I can't find the exact code.
(I have about one week of experience with j-script)

<http://jibbering.com/faq/#posting>

Suppose "j-script" means "JScript", you are probably looking for

<http://msdn.microsoft.com/en-us/library/ms535129(VS.85).aspx>

as JScript is the ECMAScript implementation that the MSHTML DOM supports.


PointedEars
 
B

Butterfly Bill

There has to be some way you can change the words you have put into a
<input type="text box because I have seen on-screen calculators that
can put your result into one. But I can't find the exact way among all
the entries in the lists of objects and other stuff. It seems to have
something with declaring a different value for the value=" part of it,
but I can't find the exact code.
(I have about one week of experience with j-script)

-Bill
 
S

Stevo

Butterfly said:
There has to be some way you can change the words you have put into a
<input type="text box because I have seen on-screen calculators that
can put your result into one. But I can't find the exact way among all
the entries in the lists of objects and other stuff. It seems to have
something with declaring a different value for the value=" part of it,
but I can't find the exact code.
(I have about one week of experience with j-script)

-Bill

<form name="myform">
<input type="text" name="mytext" value="initial">
</form>
<script>
document.forms.myform.mytext.value="changed";
</script>
 
B

Butterfly Bill

On Oct 24, 1:46 pm, Thomas 'PointedEars' Lahn <[email protected]>
wrote:

Stevo's answer worked, thank you.

Thomas, I meant javascript. I was being too lazy to write the extra
letters.

-BB
 
T

Tim Slattery

Stevo said:
<form name="myform">
<input type="text" name="mytext" value="initial">
</form>
<script>
document.forms.myform.mytext.value="changed";
</script>

Will that syntax work on all browsers?

<form name="myform">
<input type="text" id="mytext" name="mytext" value="initial">
</form>
<script>
document.getElementById("mytext").value="changed";
</script>

That's the "official" way to do it, I think.

I could quibble on the "name" property on the "form" element. I know
XHTML doesn't allow it, I'm not sure about other standards. IM(NS)HO
you should the "id" property there instead.
 
R

Richard Cornford

Will that syntax work on all browsers?

No, in an XHTML DOM on gecko browsers pre-dating about Mozilla 1.3 (if
memory serves) it would not work. In HTML DOMs nobody has ever
reported an environment where it did not work.
<form name="myform">
<input type="text" id="mytext" name="mytext" value="initial">
</form>
<script>
document.getElementById("mytext").value="changed";

Now that certainly is a less well supported alternative as it would
not work at all in pre-W3C DOM browser. The significance of that
depends on what "all browsers" is intended to mean above.
</script>

That's the "official" way to do it, I think.

Not any more official than:-

document.forms.myform.elements.mytext.value="changed";

- which is at least as widely supported as -
document.forms.myform.mytext.value="changed" -, and so supported in
(numerically) more browser than - getElementById -.
I could quibble on the "name" property on the "form" element.
I know XHTML doesn't allow it,
<snip>

As I recall the name attribute is available for form elements in XHTML
1.0 with a transitional DTD, and is not available in HTML 4.01 with a
strict DTD.

Richard.
 
E

Eric Bednarz

Richard Cornford said:
As I recall the name attribute is available for form elements in XHTML
1.0 with a transitional DTD, and is not available in HTML 4.01 with a
strict DTD.

Not really. The ‘name’ attribute for the element type ‘form’ had been
dropped completely in HTML 4.0, was completely reintroduced in HTML
4.01, and for good measure dropped again for XHTML 1.0 strict
exclusively (calling the “Differences with HTML 4†section of the excuse
for a(n XHTML 1.0) specification incomplete would be flattery).

<http://www.w3.org/TR/html4/appendix/changes.html#h-A.1.1.12>
<http://www.w3.org/TR/html4/interact/forms.html#adef-name-FORM>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top