Changing text in input text box

Discussion in 'Javascript' started by Thomas 'PointedEars' Lahn, Oct 24, 2009.

  1. <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
     
    Thomas 'PointedEars' Lahn, Oct 24, 2009
    #1
    1. Advertisements

  2. Thomas 'PointedEars' Lahn, Oct 24, 2009
    #2
    1. Advertisements

  3. 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
     
    Butterfly Bill, Oct 24, 2009
    #3
  4. Thomas 'PointedEars' Lahn

    Stevo Guest

    <form name="myform">
    <input type="text" name="mytext" value="initial">
    </form>
    <script>
    document.forms.myform.mytext.value="changed";
    </script>
     
    Stevo, Oct 24, 2009
    #4
  5. On Oct 24, 1:46 pm, Thomas 'PointedEars' Lahn <>
    wrote:

    Stevo's answer worked, thank you.

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

    -BB
     
    Butterfly Bill, Oct 25, 2009
    #5
  6. Thomas 'PointedEars' Lahn

    Tim Slattery Guest

    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.
     
    Tim Slattery, Oct 26, 2009
    #6
  7. 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.
    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.
    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 -.
    <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.
     
    Richard Cornford, Oct 26, 2009
    #7
  8. Thomas 'PointedEars' Lahn

    Eric Bednarz Guest

    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>
     
    Eric Bednarz, Oct 26, 2009
    #8
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.